| 106 | }); |
| 107 | |
| 108 | const onUpdateSubmit: FormEventHandler<HTMLFormElement> = async (e) => { |
| 109 | if (!fetchedPost?.id || !squad) { |
| 110 | return null; |
| 111 | } |
| 112 | |
| 113 | const isSameAsBefore = [fetchedPost?.title, moderated?.content].includes( |
| 114 | commentary, |
| 115 | ); |
| 116 | if (isSameAsBefore) { |
| 117 | return push(squad.permalink); |
| 118 | } |
| 119 | |
| 120 | if (moderated) { |
| 121 | return onUpdatePostModeration({ |
| 122 | type: PostType.Share, |
| 123 | sourceId: squad.id, |
| 124 | id: moderated.id, |
| 125 | title: moderated.sharedPost ? commentary : preview.title, |
| 126 | content: moderated.sharedPost ? null : commentary, |
| 127 | imageUrl: moderated.sharedPost ? null : preview.image, |
| 128 | externalLink: moderated.sharedPost ? null : preview.url, |
| 129 | }); |
| 130 | } |
| 131 | |
| 132 | return onUpdateSharePost(e, fetchedPost.id, commentary, squad); |
| 133 | }; |
| 134 | |
| 135 | const onSubmit: FormEventHandler<HTMLFormElement> = async (e) => { |
| 136 | e.preventDefault(); |