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);
}

View File

@ -1,39 +0,0 @@
// Copyright 2018-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global Whisper */
'use strict';
describe('Database', () => {
describe('handleDOMException', () => {
it('handles null, still calls reject', () => {
let called = 0;
const reject = () => {
called += 1;
};
const error = null;
const prefix = 'something';
Whisper.Database.handleDOMException(prefix, error, reject);
assert.strictEqual(called, 1);
});
it('handles object code and message', () => {
let called = 0;
const reject = () => {
called += 1;
};
const error = {
code: 4,
message: 'some cryptic error',
};
const prefix = 'something';
Whisper.Database.handleDOMException(prefix, error, reject);
assert.strictEqual(called, 1);
});
});
});

View File

@ -1,4 +1,4 @@
<!-- Copyright 2014-2021 Signal Messenger, LLC -->
<!-- Copyright 2014-2022 Signal Messenger, LLC -->
<!-- SPDX-License-Identifier: AGPL-3.0-only -->
<html>
@ -109,7 +109,6 @@
<script type="text/javascript" src="libphonenumber_util_test.js"></script>
<script type="text/javascript" src="reliable_trigger_test.js"></script>
<script type="text/javascript" src="database_test.js"></script>
<script type="text/javascript" src="i18n_test.js"></script>
<script type="text/javascript" src="stickers_test.js"></script>

View File

@ -1,13 +1,8 @@
// Copyright 2014-2020 Signal Messenger, LLC
// Copyright 2014-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global Whisper, _, Backbone */
// Override the database id.
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
Whisper.Database.id = 'test';
/*
* global helpers for tests
*/

9
ts/window.d.ts vendored
View File

@ -557,15 +557,6 @@ export type WhisperType = {
events: Backbone.Events;
activeConfirmationView: WhatIsThis;
Database: {
open: () => Promise<IDBDatabase>;
handleDOMException: (
context: string,
error: DOMException | null,
reject: Function
) => void;
};
ExpiringMessagesListener: {
init: (events: Backbone.Events) => void;
update: () => void;