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={(messageBody, bodyRanges) => {
|
||||||
onChange([{ ...lonelyDraft, messageBody, bodyRanges }]);
|
onChange([{ ...lonelyDraft, messageBody, bodyRanges }]);
|
||||||
}}
|
}}
|
||||||
|
onChangeAttachments={attachments => {
|
||||||
|
onChange([{ ...lonelyDraft, attachments }]);
|
||||||
|
}}
|
||||||
removeLinkPreview={removeLinkPreview}
|
removeLinkPreview={removeLinkPreview}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
@ -437,6 +440,7 @@ type ForwardMessageEditorProps = Readonly<{
|
||||||
bodyRanges: HydratedBodyRangesType,
|
bodyRanges: HydratedBodyRangesType,
|
||||||
caretLocation?: number
|
caretLocation?: number
|
||||||
) => unknown;
|
) => unknown;
|
||||||
|
onChangeAttachments: (attachments: ReadonlyArray<AttachmentType>) => unknown;
|
||||||
onSubmit: () => unknown;
|
onSubmit: () => unknown;
|
||||||
theme: ThemeType;
|
theme: ThemeType;
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
|
@ -449,13 +453,11 @@ function ForwardMessageEditor({
|
||||||
RenderCompositionTextArea,
|
RenderCompositionTextArea,
|
||||||
removeLinkPreview,
|
removeLinkPreview,
|
||||||
onChange,
|
onChange,
|
||||||
|
onChangeAttachments,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
theme,
|
theme,
|
||||||
}: ForwardMessageEditorProps): JSX.Element {
|
}: ForwardMessageEditorProps): JSX.Element {
|
||||||
const [attachmentsToForward, setAttachmentsToForward] = useState<
|
const { attachments } = draft;
|
||||||
ReadonlyArray<AttachmentType>
|
|
||||||
>(draft.attachments ?? []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="module-ForwardMessageModal__main-body">
|
<div className="module-ForwardMessageModal__main-body">
|
||||||
{linkPreview ? (
|
{linkPreview ? (
|
||||||
|
@ -472,15 +474,15 @@ function ForwardMessageEditor({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{attachmentsToForward && attachmentsToForward.length ? (
|
{attachments != null && attachments.length > 0 ? (
|
||||||
<AttachmentList
|
<AttachmentList
|
||||||
attachments={attachmentsToForward}
|
attachments={attachments}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
onCloseAttachment={(attachment: AttachmentType) => {
|
onCloseAttachment={(attachment: AttachmentType) => {
|
||||||
const newAttachments = attachmentsToForward.filter(
|
const newAttachments = attachments.filter(
|
||||||
currentAttachment => currentAttachment !== attachment
|
currentAttachment => currentAttachment !== attachment
|
||||||
);
|
);
|
||||||
setAttachmentsToForward(newAttachments);
|
onChangeAttachments(newAttachments);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue