fix: sessionconfirm on click callback accepts arguments

now delete modal supports delete for me or everyone
pull/3017/head
William Grant 1 year ago
parent 28517b7624
commit dbd95fbf35

@ -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> | void;
onClickOk?: (...args: Array<any>) => Promise<void> | 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 {

@ -381,16 +381,16 @@ export async function deleteMessagesById(messageIds: Array<string>, 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));
},

Loading…
Cancel
Save