From 426f2000b82ba2dce85c030cb39602676c2f8805 Mon Sep 17 00:00:00 2001 From: audric Date: Fri, 6 Aug 2021 16:26:56 +1000 Subject: [PATCH] fixup delete all and handle errors --- _locales/en/messages.json | 5 ++-- ts/components/dialog/DeleteAccountModal.tsx | 25 +++++++++++-------- .../session/LeftPaneSettingSection.tsx | 12 +-------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 6ff65f46c..442a633ef 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -421,8 +421,9 @@ "sendRecoveryPhraseMessage": "You are attempting to send your recovery phrase which can be used to access your account. Are you sure you want to send this message?", "notificationSubtitle": "Notifications - $setting$", "dialogClearAllDataDeletionFailedTitle": "Data not deleted", - "dialogClearAllDataDeletionFailedDesc": "Data not deleted with an unknown error", - "dialogClearAllDataDeletionFailedMultiple": "Data not deleted by all those Service Nodes: $snodes$", + "dialogClearAllDataDeletionFailedDesc": "Data not deleted with an unknown error. Do you want to delete data from just this device?", + "dialogClearAllDataDeletionFailedTitleQuestion": "Do you want to delete data from just this device?", + "dialogClearAllDataDeletionFailedMultiple": "Data not deleted by those Service Nodes: $snodes$", "dialogClearAllDataDeletionQuestion": "Would you like to clear only this device, or delete your entire account?", "deviceOnly": "Device Only", "entireAccount": "Entire Account" diff --git a/ts/components/dialog/DeleteAccountModal.tsx b/ts/components/dialog/DeleteAccountModal.tsx index 83a6aa3ce..b0e948019 100644 --- a/ts/components/dialog/DeleteAccountModal.tsx +++ b/ts/components/dialog/DeleteAccountModal.tsx @@ -58,11 +58,14 @@ async function deleteEverythingAndNetworkData() { if (potentiallyMaliciousSnodes === null) { window?.log?.warn('DeleteAccount => forceNetworkDeletion failed'); + // close this dialog + window.inboxStore?.dispatch(updateDeleteAccountModal(null)); window.inboxStore?.dispatch( updateConfirmModal({ title: window.i18n('dialogClearAllDataDeletionFailedTitle'), message: window.i18n('dialogClearAllDataDeletionFailedDesc'), okTheme: SessionButtonColor.Danger, + okText: window.i18n('deviceOnly'), onClickOk: async () => { await deleteDbLocally(); window.restart(); @@ -78,11 +81,19 @@ async function deleteEverythingAndNetworkData() { 'DeleteAccount => forceNetworkDeletion Got some potentially malicious snodes', snodeStr ); + // close this dialog + window.inboxStore?.dispatch(updateDeleteAccountModal(null)); + // open a new confirm dialog to ask user what to do window.inboxStore?.dispatch( updateConfirmModal({ title: window.i18n('dialogClearAllDataDeletionFailedTitle'), - message: window.i18n('dialogClearAllDataDeletionFailedMultiple', snodeStr), + message: window.i18n( + 'dialogClearAllDataDeletionFailedMultiple', + potentiallyMaliciousSnodes.join(', ') + ), + messageSub: window.i18n('dialogClearAllDataDeletionFailedTitleQuestion'), okTheme: SessionButtonColor.Danger, + okText: window.i18n('deviceOnly'), onClickOk: async () => { await deleteDbLocally(); window.restart(); @@ -128,7 +139,7 @@ export const DeleteAccountModal = () => { setIsLoading(false); } - dispatch(updateConfirmModal(null)); + window.inboxStore?.dispatch(updateConfirmModal(null)); }; const onDeleteEverythingAndNetworkData = async () => { setIsLoading(true); @@ -140,8 +151,6 @@ export const DeleteAccountModal = () => { } finally { setIsLoading(false); } - - dispatch(updateConfirmModal(null)); }; /** @@ -181,7 +190,7 @@ export const DeleteAccountModal = () => { @@ -192,9 +201,3 @@ export const DeleteAccountModal = () => { ); }; -function dispatch(arg0: { - payload: import('../../state/ducks/modalDialog').ConfirmModalState; - type: string; -}) { - throw new Error('Function not implemented.'); -} diff --git a/ts/components/session/LeftPaneSettingSection.tsx b/ts/components/session/LeftPaneSettingSection.tsx index 34abb5344..fb71e90c2 100644 --- a/ts/components/session/LeftPaneSettingSection.tsx +++ b/ts/components/session/LeftPaneSettingSection.tsx @@ -11,17 +11,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { showSettingsSection } from '../../state/ducks/section'; import { getFocusedSettingsSection } from '../../state/selectors/section'; import { getTheme } from '../../state/selectors/theme'; -import { - recoveryPhraseModal, - updateConfirmModal, - updateDeleteAccountModal, -} from '../../state/ducks/modalDialog'; - -type Props = { - settingsCategory: SessionSettingCategory; - showSettingsSection: (category: SessionSettingCategory) => void; - theme: DefaultTheme; -}; +import { recoveryPhraseModal, updateDeleteAccountModal } from '../../state/ducks/modalDialog'; const getCategories = () => { return [