@@ -489,7 +489,10 @@ function attachmentContextRecord(
489489 : { ...common , kind : "file" as const } ;
490490}
491491
492- function restoreMissingComposerFileReferences ( draft : ComposerDraft ) : ComposerDraft {
492+ function restoreMissingComposerFileReferences (
493+ draft : ComposerDraft ,
494+ attachments = draft . attachments ,
495+ ) : ComposerDraft {
493496 const records = [ ...( draft . context ?. records ?? [ ] ) ] ;
494497 const usedIds = new Set < string > ( records . map ( ( record ) => record . contextId ) ) ;
495498 const referenced = new Set (
@@ -499,7 +502,7 @@ function restoreMissingComposerFileReferences(draft: ComposerDraft): ComposerDra
499502 ) ;
500503 let text = draft . text ;
501504 let changed = false ;
502- for ( const attachment of draft . attachments ) {
505+ for ( const attachment of attachments ) {
503506 if (
504507 attachment . type === "image" ||
505508 imageMimeType ( attachment ) !== null ||
@@ -1580,13 +1583,16 @@ export function mergeComposerDraftContentState(
15801583 ...current ,
15811584 // The composer shows non-image files only as inline chips, so a shared file
15821585 // merged without one would be attached but invisible until sent.
1583- [ draftKey ] : restoreMissingComposerFileReferences ( {
1584- ...existing ,
1585- text,
1586- attachments,
1587- context,
1588- ...( importedShareIds ? { importedShareIds } : { } ) ,
1589- } ) ,
1586+ [ draftKey ] : restoreMissingComposerFileReferences (
1587+ {
1588+ ...existing ,
1589+ text,
1590+ attachments,
1591+ context,
1592+ ...( importedShareIds ? { importedShareIds } : { } ) ,
1593+ } ,
1594+ attachments . slice ( existing . attachments . length ) ,
1595+ ) ,
15901596 } ;
15911597}
15921598
0 commit comments