Remove old Whisper.Database module

This commit is contained in:
Evan Hahn 2022-05-27 22:12:01 +00:00 committed by GitHub
parent 1184756866
commit 11cfb4f76f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 85 deletions

View file

@ -1,22 +0,0 @@
// Copyright 2014-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global Whisper: false */
// eslint-disable-next-line func-names
(function () {
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
window.Whisper.Database.id = window.Whisper.Database.id || 'signal';
window.Whisper.Database.nolog = true;
Whisper.Database.handleDOMException = (prefix, error, reject) => {
window.SignalContext.log.error(
`${prefix}:`,
error && error.name,
error && error.message,
error && error.code
);
reject(error || new Error(prefix));
};
})();

View file

@ -1,8 +1,9 @@
// Copyright 2018-2020 Signal Messenger, LLC
// Copyright 2018-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global window, Whisper, clearTimeout, setTimeout */
/* global window, clearTimeout, setTimeout */
const LEGACY_DATABASE_ID = 'signal';
const MESSAGE_MINIMUM_VERSION = 7;
module.exports = {
@ -16,8 +17,7 @@ async function doesDatabaseExist() {
'Checking for the existence of IndexedDB data...'
);
return new Promise((resolve, reject) => {
const { id } = Whisper.Database;
const req = window.indexedDB.open(id);
const req = window.indexedDB.open(LEGACY_DATABASE_ID);
let existed = true;
@ -47,7 +47,7 @@ async function doesDatabaseExist() {
req.onupgradeneeded = () => {
if (req.result.version === 1) {
existed = false;
window.indexedDB.deleteDatabase(id);
window.indexedDB.deleteDatabase(LEGACY_DATABASE_ID);
}
};
});
@ -55,7 +55,7 @@ async function doesDatabaseExist() {
function removeDatabase() {
window.SignalContext.log.info(
`Deleting IndexedDB database '${Whisper.Database.id}'`
`Deleting IndexedDB database '${LEGACY_DATABASE_ID}'`
);
window.indexedDB.deleteDatabase(Whisper.Database.id);
window.indexedDB.deleteDatabase(LEGACY_DATABASE_ID);
}