fixup delete all and handle errors

pull/1833/head
audric 4 years ago
parent e9412df60e
commit 426f2000b8

@ -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?", "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$", "notificationSubtitle": "Notifications - $setting$",
"dialogClearAllDataDeletionFailedTitle": "Data not deleted", "dialogClearAllDataDeletionFailedTitle": "Data not deleted",
"dialogClearAllDataDeletionFailedDesc": "Data not deleted with an unknown error", "dialogClearAllDataDeletionFailedDesc": "Data not deleted with an unknown error. Do you want to delete data from just this device?",
"dialogClearAllDataDeletionFailedMultiple": "Data not deleted by all those Service Nodes: $snodes$", "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?", "dialogClearAllDataDeletionQuestion": "Would you like to clear only this device, or delete your entire account?",
"deviceOnly": "Device Only", "deviceOnly": "Device Only",
"entireAccount": "Entire Account" "entireAccount": "Entire Account"

@ -58,11 +58,14 @@ async function deleteEverythingAndNetworkData() {
if (potentiallyMaliciousSnodes === null) { if (potentiallyMaliciousSnodes === null) {
window?.log?.warn('DeleteAccount => forceNetworkDeletion failed'); window?.log?.warn('DeleteAccount => forceNetworkDeletion failed');
// close this dialog
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('dialogClearAllDataDeletionFailedTitle'), title: window.i18n('dialogClearAllDataDeletionFailedTitle'),
message: window.i18n('dialogClearAllDataDeletionFailedDesc'), message: window.i18n('dialogClearAllDataDeletionFailedDesc'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,
okText: window.i18n('deviceOnly'),
onClickOk: async () => { onClickOk: async () => {
await deleteDbLocally(); await deleteDbLocally();
window.restart(); window.restart();
@ -78,11 +81,19 @@ async function deleteEverythingAndNetworkData() {
'DeleteAccount => forceNetworkDeletion Got some potentially malicious snodes', 'DeleteAccount => forceNetworkDeletion Got some potentially malicious snodes',
snodeStr snodeStr
); );
// close this dialog
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
// open a new confirm dialog to ask user what to do
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('dialogClearAllDataDeletionFailedTitle'), title: window.i18n('dialogClearAllDataDeletionFailedTitle'),
message: window.i18n('dialogClearAllDataDeletionFailedMultiple', snodeStr), message: window.i18n(
'dialogClearAllDataDeletionFailedMultiple',
potentiallyMaliciousSnodes.join(', ')
),
messageSub: window.i18n('dialogClearAllDataDeletionFailedTitleQuestion'),
okTheme: SessionButtonColor.Danger, okTheme: SessionButtonColor.Danger,
okText: window.i18n('deviceOnly'),
onClickOk: async () => { onClickOk: async () => {
await deleteDbLocally(); await deleteDbLocally();
window.restart(); window.restart();
@ -128,7 +139,7 @@ export const DeleteAccountModal = () => {
setIsLoading(false); setIsLoading(false);
} }
dispatch(updateConfirmModal(null)); window.inboxStore?.dispatch(updateConfirmModal(null));
}; };
const onDeleteEverythingAndNetworkData = async () => { const onDeleteEverythingAndNetworkData = async () => {
setIsLoading(true); setIsLoading(true);
@ -140,8 +151,6 @@ export const DeleteAccountModal = () => {
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
dispatch(updateConfirmModal(null));
}; };
/** /**
@ -181,7 +190,7 @@ export const DeleteAccountModal = () => {
<SessionButton <SessionButton
text={window.i18n('deviceOnly')} text={window.i18n('deviceOnly')}
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Primary}
onClick={onDeleteEverythingLocallyOnly} onClick={onDeleteEverythingLocallyOnly}
disabled={isLoading} disabled={isLoading}
/> />
@ -192,9 +201,3 @@ export const DeleteAccountModal = () => {
</SessionWrapperModal> </SessionWrapperModal>
); );
}; };
function dispatch(arg0: {
payload: import('../../state/ducks/modalDialog').ConfirmModalState;
type: string;
}) {
throw new Error('Function not implemented.');
}

@ -11,17 +11,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { showSettingsSection } from '../../state/ducks/section'; import { showSettingsSection } from '../../state/ducks/section';
import { getFocusedSettingsSection } from '../../state/selectors/section'; import { getFocusedSettingsSection } from '../../state/selectors/section';
import { getTheme } from '../../state/selectors/theme'; import { getTheme } from '../../state/selectors/theme';
import { import { recoveryPhraseModal, updateDeleteAccountModal } from '../../state/ducks/modalDialog';
recoveryPhraseModal,
updateConfirmModal,
updateDeleteAccountModal,
} from '../../state/ducks/modalDialog';
type Props = {
settingsCategory: SessionSettingCategory;
showSettingsSection: (category: SessionSettingCategory) => void;
theme: DefaultTheme;
};
const getCategories = () => { const getCategories = () => {
return [ return [

Loading…
Cancel
Save