2021-08-24 20:57:34 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
import * as log from '../logging/log';
|
2021-09-21 00:25:29 +00:00
|
|
|
import { deleteAllLogs } from '../util/deleteAllLogs';
|
2022-11-22 18:43:43 +00:00
|
|
|
import * as Errors from '../types/errors';
|
2021-09-17 18:27:53 +00:00
|
|
|
|
2021-08-24 20:57:34 +00:00
|
|
|
export async function deleteAllData(): Promise<void> {
|
|
|
|
try {
|
2021-09-21 00:25:29 +00:00
|
|
|
await deleteAllLogs();
|
2021-08-24 20:57:34 +00:00
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info('deleteAllData: deleted all logs');
|
2021-08-24 20:57:34 +00:00
|
|
|
|
|
|
|
await window.Signal.Data.removeAll();
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info('deleteAllData: emptied database');
|
2021-08-24 20:57:34 +00:00
|
|
|
|
|
|
|
await window.Signal.Data.close();
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info('deleteAllData: closed database');
|
2021-08-24 20:57:34 +00:00
|
|
|
|
|
|
|
await window.Signal.Data.removeDB();
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info('deleteAllData: removed database');
|
2021-08-24 20:57:34 +00:00
|
|
|
|
|
|
|
await window.Signal.Data.removeOtherData();
|
|
|
|
|
2021-09-17 18:27:53 +00:00
|
|
|
log.info('deleteAllData: removed all other data');
|
2021-08-24 20:57:34 +00:00
|
|
|
} catch (error) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error(
|
2021-08-24 20:57:34 +00:00
|
|
|
'Something went wrong deleting all data:',
|
2022-11-22 18:43:43 +00:00
|
|
|
Errors.toLogFormat(error)
|
2021-08-24 20:57:34 +00:00
|
|
|
);
|
|
|
|
}
|
2023-11-06 21:19:23 +00:00
|
|
|
window.SignalContext.restartApp();
|
2021-08-24 20:57:34 +00:00
|
|
|
}
|