From dbd95fbf35fd0fa619a4ef5d2b8affb3a9c607d8 Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 24 Jan 2024 12:27:43 +1100 Subject: [PATCH] fix: sessionconfirm on click callback accepts arguments now delete modal supports delete for me or everyone --- ts/components/dialog/SessionConfirm.tsx | 5 +++-- ts/interactions/conversations/unsendingInteractions.ts | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ts/components/dialog/SessionConfirm.tsx b/ts/components/dialog/SessionConfirm.tsx index dfaabb24f..771c7f9be 100644 --- a/ts/components/dialog/SessionConfirm.tsx +++ b/ts/components/dialog/SessionConfirm.tsx @@ -32,8 +32,9 @@ export interface SessionConfirmDialogProps { /** * function to run on ok click. Closes modal after execution by default + * sometimes the callback might need arguments when using radioOptions */ - onClickOk?: () => Promise | void; + onClickOk?: (...args: Array) => Promise | void; onClickClose?: () => any; @@ -84,7 +85,7 @@ export const SessionConfirm = (props: SessionConfirmDialogProps) => { if (onClickOk) { setIsLoading(true); try { - await onClickOk(); + await onClickOk(chosenOption !== '' ? chosenOption : undefined); } catch (e) { window.log.warn(e); } finally { diff --git a/ts/interactions/conversations/unsendingInteractions.ts b/ts/interactions/conversations/unsendingInteractions.ts index d7d6e8369..84c062883 100644 --- a/ts/interactions/conversations/unsendingInteractions.ts +++ b/ts/interactions/conversations/unsendingInteractions.ts @@ -381,16 +381,16 @@ export async function deleteMessagesById(messageIds: Array, conversation ? window.i18n('deleteMessagesQuestion', [messageCount.toString()]) : window.i18n('deleteMessageQuestion'), radioOptions: [ - { label: window.i18n('deleteJustForMe'), value: window.i18n('deleteJustForMe') }, - { label: window.i18n('deleteForEveryone'), value: window.i18n('deleteForEveryone') }, + { label: window.i18n('deleteJustForMe'), value: 'deleteJustForMe' }, + { label: window.i18n('deleteForEveryone'), value: 'deleteForEveryone' }, ], okText: window.i18n('delete'), okTheme: SessionButtonColor.Danger, - onClickOk: async () => { + onClickOk: async args => { await doDeleteSelectedMessages({ selectedMessages, conversation, - deleteForEveryone: false, + deleteForEveryone: args === 'deleteForEveryone', // chosenOption from radioOptions }); window.inboxStore?.dispatch(updateConfirmModal(null)); },