diff --git a/js/modules/signal.js b/js/modules/signal.js index 47450703b..b2e02900b 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -13,7 +13,6 @@ const Data = require('../../ts/sql/Client').default; const EmojiLib = require('../../ts/components/emoji/lib'); const Groups = require('../../ts/groups'); const GroupChange = require('../../ts/groupChange'); -const IndexedDB = require('./indexeddb'); const OS = require('../../ts/OS'); const Stickers = require('../../ts/types/Stickers'); const RemoteConfig = require('../../ts/RemoteConfig'); @@ -419,7 +418,6 @@ exports.setup = (options = {}) => { EmojiLib, Groups, GroupChange, - IndexedDB, Migrations, OS, RemoteConfig, diff --git a/ts/background.ts b/ts/background.ts index f15d9e86e..13b603ebc 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -24,6 +24,7 @@ import type { } from './model-types.d'; import * as Bytes from './Bytes'; import * as Timers from './Timers'; +import * as indexedDb from './indexeddb'; import type { WhatIsThis } from './window.d'; import type { Receipt } from './types/Receipt'; import { getTitleBarVisibility, TitleBarVisibility } from './types/Settings'; @@ -494,8 +495,6 @@ export async function startApp(): Promise { // of preload.js processing window.setImmediate = window.nodeSetImmediate; - const { removeDatabase: removeIndexedDB, doesDatabaseExist } = - window.Signal.IndexedDB; const { Message } = window.Signal.Types; const { upgradeMessageSchema, @@ -551,7 +550,7 @@ export async function startApp(): Promise { const version = await window.Signal.Data.getItemById('version'); if (!version) { - const isIndexedDBPresent = await doesDatabaseExist(); + const isIndexedDBPresent = await indexedDb.doesDatabaseExist(); if (isIndexedDBPresent) { log.info('Found IndexedDB database.'); try { @@ -582,7 +581,7 @@ export async function startApp(): Promise { log.info('Deleting IndexedDB file...'); await Promise.all([ - removeIndexedDB(), + indexedDb.removeDatabase(), window.Signal.Data.removeAll(), window.Signal.Data.removeIndexedDBFiles(), ]); diff --git a/js/modules/indexeddb.js b/ts/indexeddb.ts similarity index 81% rename from js/modules/indexeddb.js rename to ts/indexeddb.ts index 4f1e38d7f..19f1f3ab0 100644 --- a/js/modules/indexeddb.js +++ b/ts/indexeddb.ts @@ -1,18 +1,9 @@ // Copyright 2018-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -/* global window, clearTimeout, setTimeout */ - const LEGACY_DATABASE_ID = 'signal'; -const MESSAGE_MINIMUM_VERSION = 7; -module.exports = { - doesDatabaseExist, - MESSAGE_MINIMUM_VERSION, - removeDatabase, -}; - -async function doesDatabaseExist() { +export async function doesDatabaseExist(): Promise { window.SignalContext.log.info( 'Checking for the existence of IndexedDB data...' ); @@ -21,7 +12,7 @@ async function doesDatabaseExist() { let existed = true; - let timer = setTimeout(() => { + let timer: undefined | ReturnType = setTimeout(() => { window.SignalContext.log.warn( 'doesDatabaseExist: Timed out attempting to check IndexedDB status' ); @@ -53,7 +44,7 @@ async function doesDatabaseExist() { }); } -function removeDatabase() { +export function removeDatabase(): void { window.SignalContext.log.info( `Deleting IndexedDB database '${LEGACY_DATABASE_ID}'` ); diff --git a/ts/window.d.ts b/ts/window.d.ts index 5df00531d..373a3dfe7 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -398,10 +398,6 @@ declare global { WhatsNewLink: typeof WhatsNewLink; }; OS: typeof OS; - IndexedDB: { - removeDatabase: WhatIsThis; - doesDatabaseExist: WhatIsThis; - }; Views: WhatIsThis; State: { createStore: typeof createStore;