diff --git a/js/database.js b/js/database.js deleted file mode 100644 index 2746c41c8..000000000 --- a/js/database.js +++ /dev/null @@ -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)); - }; -})(); diff --git a/js/modules/indexeddb.js b/js/modules/indexeddb.js index 40242be9e..4f1e38d7f 100644 --- a/js/modules/indexeddb.js +++ b/js/modules/indexeddb.js @@ -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); } diff --git a/test/database_test.js b/test/database_test.js deleted file mode 100644 index 709db3ae5..000000000 --- a/test/database_test.js +++ /dev/null @@ -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); - }); - }); -}); diff --git a/test/index.html b/test/index.html index 6922667d0..4d63fee3b 100644 --- a/test/index.html +++ b/test/index.html @@ -1,4 +1,4 @@ - + @@ -109,7 +109,6 @@ - diff --git a/test/test.js b/test/test.js index bcbe639b6..33f5fc5c8 100644 --- a/test/test.js +++ b/test/test.js @@ -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 */ diff --git a/ts/window.d.ts b/ts/window.d.ts index 2735f05af..e160745c5 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -557,15 +557,6 @@ export type WhisperType = { events: Backbone.Events; activeConfirmationView: WhatIsThis; - Database: { - open: () => Promise; - handleDOMException: ( - context: string, - error: DOMException | null, - reject: Function - ) => void; - }; - ExpiringMessagesListener: { init: (events: Backbone.Events) => void; update: () => void;