Update drafts when removing attachments in forward modal
This commit is contained in:
parent
406916ea42
commit
1eddf252e1
1 changed files with 10 additions and 8 deletions
|
@ -318,6 +318,9 @@ export function ForwardMessagesModal({
|
|||
onChange={(messageBody, bodyRanges) => {
|
||||
onChange([{ ...lonelyDraft, messageBody, bodyRanges }]);
|
||||
}}
|
||||
onChangeAttachments={attachments => {
|
||||
onChange([{ ...lonelyDraft, attachments }]);
|
||||
}}
|
||||
removeLinkPreview={removeLinkPreview}
|
||||
theme={theme}
|
||||
i18n={i18n}
|
||||
|
@ -437,6 +440,7 @@ type ForwardMessageEditorProps = Readonly<{
|
|||
bodyRanges: HydratedBodyRangesType,
|
||||
caretLocation?: number
|
||||
) => unknown;
|
||||
onChangeAttachments: (attachments: ReadonlyArray<AttachmentType>) => unknown;
|
||||
onSubmit: () => unknown;
|
||||
theme: ThemeType;
|
||||
i18n: LocalizerType;
|
||||
|
@ -449,13 +453,11 @@ function ForwardMessageEditor({
|
|||
RenderCompositionTextArea,
|
||||
removeLinkPreview,
|
||||
onChange,
|
||||
onChangeAttachments,
|
||||
onSubmit,
|
||||
theme,
|
||||
}: ForwardMessageEditorProps): JSX.Element {
|
||||
const [attachmentsToForward, setAttachmentsToForward] = useState<
|
||||
ReadonlyArray<AttachmentType>
|
||||
>(draft.attachments ?? []);
|
||||
|
||||
const { attachments } = draft;
|
||||
return (
|
||||
<div className="module-ForwardMessageModal__main-body">
|
||||
{linkPreview ? (
|
||||
|
@ -472,15 +474,15 @@ function ForwardMessageEditor({
|
|||
/>
|
||||
</div>
|
||||
) : null}
|
||||
{attachmentsToForward && attachmentsToForward.length ? (
|
||||
{attachments != null && attachments.length > 0 ? (
|
||||
<AttachmentList
|
||||
attachments={attachmentsToForward}
|
||||
attachments={attachments}
|
||||
i18n={i18n}
|
||||
onCloseAttachment={(attachment: AttachmentType) => {
|
||||
const newAttachments = attachmentsToForward.filter(
|
||||
const newAttachments = attachments.filter(
|
||||
currentAttachment => currentAttachment !== attachment
|
||||
);
|
||||
setAttachmentsToForward(newAttachments);
|
||||
onChangeAttachments(newAttachments);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
|
Loading…
Add table
Reference in a new issue