@@ -88,12 +88,13 @@ export const useSubmitHandler = <
8888 return addNotification ( t ( 'Wait until all attachments have uploaded' ) , 'error' ) ;
8989 }
9090
91- const attachmentsFromUploads = attachments
92- . filter (
93- ( att ) =>
94- att . localMetadata ?. uploadState !== 'failed' ||
95- ( findAndEnqueueURLsToEnrich && ! att . og_scrape_url ) , // filter out all the attachments scraped before the message was edited
96- )
91+ const attachmentsWithoutLinkPreviews = attachments
92+ . filter ( ( att ) => {
93+ const isSuccessfulUpload = att . localMetadata ?. uploadState === 'finished' ;
94+ const isNotUpload = ! att . localMetadata ?. uploadState ;
95+ const isNotLinkPreview = ! att . og_scrape_url ;
96+ return isNotLinkPreview && ( isSuccessfulUpload || isNotUpload ) ;
97+ } )
9798 . map ( ( localAttachment ) => {
9899 // eslint-disable-next-line @typescript-eslint/no-unused-vars
99100 const { localMetadata : _ , ...attachment } = localAttachment ;
@@ -116,14 +117,7 @@ export const useSubmitHandler = <
116117 attachmentsFromLinkPreviews = someLinkPreviewsLoading
117118 ? [ ]
118119 : Array . from ( linkPreviews . values ( ) )
119- . filter (
120- ( linkPreview ) =>
121- linkPreview . state === LinkPreviewState . LOADED &&
122- ! attachmentsFromUploads . find (
123- ( attFromUpload ) =>
124- attFromUpload . og_scrape_url === linkPreview . og_scrape_url ,
125- ) ,
126- )
120+ . filter ( ( linkPreview ) => linkPreview . state === LinkPreviewState . LOADED )
127121
128122 . map (
129123 // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -137,7 +131,10 @@ export const useSubmitHandler = <
137131 someLinkPreviewsDismissed ;
138132 }
139133
140- const newAttachments = [ ...attachmentsFromUploads , ...attachmentsFromLinkPreviews ] ;
134+ const newAttachments = [
135+ ...attachmentsWithoutLinkPreviews ,
136+ ...attachmentsFromLinkPreviews ,
137+ ] ;
141138
142139 // Instead of checking if a user is still mentioned every time the text changes,
143140 // just filter out non-mentioned users before submit, which is cheaper
0 commit comments