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?",
"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"

@ -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 = () => {
<SessionButton
text={window.i18n('deviceOnly')}
buttonColor={SessionButtonColor.Danger}
buttonColor={SessionButtonColor.Primary}
onClick={onDeleteEverythingLocallyOnly}
disabled={isLoading}
/>
@ -192,9 +201,3 @@ export const DeleteAccountModal = () => {
</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 { 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 [

Loading…
Cancel
Save