Ask confirm before delete account (#1910)
* disable sending on enter while composing Fixes #1899 #1497 * ask confirmation before deleting account * fix app start delete db when passowrd error * fix double dialog issue with delete account * fixup login screen
This commit is contained in:
parent
25453ee807
commit
ab75f945ff
1
main.js
1
main.js
|
@ -662,6 +662,7 @@ function getDefaultSQLKey() {
|
|||
}
|
||||
|
||||
async function removeDB() {
|
||||
// this don't remove attachments and stuff like that...
|
||||
const userDir = await getRealPath(app.getPath('userData'));
|
||||
await sql.removeDB(userDir);
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ window.getEnvironment = () => config.environment;
|
|||
window.getVersion = () => config.version;
|
||||
window.getAppInstance = () => config.appInstance;
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const ipc = electron.ipcRenderer;
|
||||
const { SessionPasswordPrompt } = require('./ts/components/session/SessionPasswordPrompt');
|
||||
|
||||
window.Signal = {
|
||||
|
@ -34,21 +31,11 @@ window.Signal = {
|
|||
|
||||
window.Signal.Logs = require('./js/modules/logs');
|
||||
|
||||
window.resetDatabase = () => {
|
||||
window.clearLocalData = async () => {
|
||||
window.log.info('reset database');
|
||||
ipcRenderer.send('resetDatabase');
|
||||
};
|
||||
|
||||
window.restart = () => {
|
||||
window.log.info('restart');
|
||||
ipc.send('restart');
|
||||
};
|
||||
|
||||
window.clearLocalData = async () => {
|
||||
window.resetDatabase();
|
||||
window.restart();
|
||||
};
|
||||
|
||||
window.onLogin = passPhrase =>
|
||||
new Promise((resolve, reject) => {
|
||||
ipcRenderer.once('password-window-login-response', (event, error) => {
|
||||
|
|
|
@ -156,11 +156,6 @@ window.restart = () => {
|
|||
ipc.send('restart');
|
||||
};
|
||||
|
||||
window.resetDatabase = () => {
|
||||
window.log.info('reset database');
|
||||
ipc.send('resetDatabase');
|
||||
};
|
||||
|
||||
ipc.on('mediaPermissionsChanged', () => {
|
||||
Whisper.events.trigger('mediaPermissionsChanged');
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ import { SessionSpinner } from '../session/SessionSpinner';
|
|||
import { SessionWrapperModal } from '../session/SessionWrapperModal';
|
||||
|
||||
const deleteDbLocally = async () => {
|
||||
window?.log?.info('configuration message sent successfully. Deleting everything');
|
||||
window?.log?.info('last message sent successfully. Deleting everything');
|
||||
window.persistStore?.purge();
|
||||
await window.Signal.Logs.deleteAll();
|
||||
await window.Signal.Data.removeAll();
|
||||
|
@ -128,61 +128,44 @@ async function deleteEverythingAndNetworkData() {
|
|||
|
||||
export const DeleteAccountModal = () => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [deleteDeviceOnly, setDeleteDeviceOnly] = useState(false);
|
||||
const [deleteEverythingWithNetwork, setDeleteEverythingWithNetwork] = useState(false);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const onDeleteEverythingLocallyOnly = () => {
|
||||
dispatch(
|
||||
updateConfirmModal({
|
||||
message: window.i18n('areYouSureDeleteDeviceOnly'),
|
||||
okText: window.i18n('iAmSure'),
|
||||
okTheme: SessionButtonColor.Danger,
|
||||
onClickOk: async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything on device but keeping network data');
|
||||
const onDeleteEverythingLocallyOnly = async () => {
|
||||
if (!isLoading) {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything on device but keeping network data');
|
||||
|
||||
await sendConfigMessageAndDeleteEverything();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
},
|
||||
onClickClose: () => {
|
||||
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||
},
|
||||
})
|
||||
);
|
||||
await sendConfigMessageAndDeleteEverything();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
const onDeleteEverythingAndNetworkData = () => {
|
||||
dispatch(
|
||||
updateConfirmModal({
|
||||
message: window.i18n('areYouSureDeleteEntireAccount'),
|
||||
okText: window.i18n('iAmSure'),
|
||||
okTheme: SessionButtonColor.Danger,
|
||||
onClickOk: async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything including network data');
|
||||
await deleteEverythingAndNetworkData();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
},
|
||||
onClickClose: () => {
|
||||
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||
},
|
||||
})
|
||||
);
|
||||
const onDeleteEverythingAndNetworkData = async () => {
|
||||
if (!isLoading) {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
window.log.warn('Deleting everything including network data');
|
||||
await deleteEverythingAndNetworkData();
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs specified on close action then removes the modal.
|
||||
*/
|
||||
const onClickCancelHandler = useCallback(() => {
|
||||
window.inboxStore?.dispatch(updateDeleteAccountModal(null));
|
||||
dispatch(updateDeleteAccountModal(null));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
@ -209,17 +192,65 @@ export const DeleteAccountModal = () => {
|
|||
<SessionButton
|
||||
text={window.i18n('entireAccount')}
|
||||
buttonColor={SessionButtonColor.Danger}
|
||||
onClick={onDeleteEverythingAndNetworkData}
|
||||
disabled={isLoading}
|
||||
onClick={() => {
|
||||
setDeleteEverythingWithNetwork(true);
|
||||
}}
|
||||
disabled={deleteEverythingWithNetwork || deleteDeviceOnly}
|
||||
/>
|
||||
|
||||
<SessionButton
|
||||
text={window.i18n('deviceOnly')}
|
||||
buttonColor={SessionButtonColor.Primary}
|
||||
onClick={onDeleteEverythingLocallyOnly}
|
||||
disabled={isLoading}
|
||||
onClick={() => {
|
||||
setDeleteDeviceOnly(true);
|
||||
}}
|
||||
disabled={deleteEverythingWithNetwork || deleteDeviceOnly}
|
||||
/>
|
||||
</div>
|
||||
<SpacerLG />
|
||||
|
||||
{deleteEverythingWithNetwork && (
|
||||
<SessionHtmlRenderer
|
||||
tag="span"
|
||||
className="session-confirm-main-message"
|
||||
html={window.i18n('areYouSureDeleteEntireAccount')}
|
||||
/>
|
||||
)}
|
||||
|
||||
{deleteDeviceOnly && (
|
||||
<SessionHtmlRenderer
|
||||
tag="span"
|
||||
className="session-confirm-main-message"
|
||||
html={window.i18n('areYouSureDeleteDeviceOnly')}
|
||||
/>
|
||||
)}
|
||||
<SpacerLG />
|
||||
|
||||
{(deleteDeviceOnly || deleteEverythingWithNetwork) && (
|
||||
<div className="session-modal__button-group">
|
||||
<SessionButton
|
||||
text={window.i18n('iAmSure')}
|
||||
buttonColor={SessionButtonColor.Danger}
|
||||
onClick={() => {
|
||||
if (deleteDeviceOnly) {
|
||||
void onDeleteEverythingLocallyOnly();
|
||||
} else if (deleteEverythingWithNetwork) {
|
||||
void onDeleteEverythingAndNetworkData();
|
||||
}
|
||||
}}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
|
||||
<SessionButton
|
||||
text={window.i18n('cancel')}
|
||||
buttonColor={SessionButtonColor.Primary}
|
||||
onClick={() => {
|
||||
dispatch(updateDeleteAccountModal(null));
|
||||
}}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SessionSpinner loading={isLoading} />
|
||||
</div>
|
||||
|
|
|
@ -71,7 +71,7 @@ const SignUpSessionIDShown = (props: { continueSignUp: () => void }) => {
|
|||
</div>
|
||||
</Flex>
|
||||
<SessionIdEditable editable={false} placeholder={undefined} />
|
||||
<div className="session-description-long">{window.i18n('signupSessionIDBlurb')}</div>
|
||||
<div className="session-description-long">{window.i18n('allUsersAreRandomly...')}</div>
|
||||
<ContinueSignUpButton continueSignUp={props.continueSignUp} />
|
||||
<TermsAndConditions />
|
||||
</div>
|
||||
|
|
|
@ -51,7 +51,6 @@ declare global {
|
|||
lokiSnodeAPI: LokiSnodeAPI;
|
||||
onLogin: any;
|
||||
persistStore?: Persistor;
|
||||
resetDatabase: any;
|
||||
restart: any;
|
||||
getSeedNodeList: () => Array<any> | undefined;
|
||||
setPassword: any;
|
||||
|
|
Loading…
Reference in New Issue