From b410d14753bc8cc0b4b8fb3f25d747a5546323fd Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:53:29 -0800 Subject: [PATCH] Remove unused storage keys --- ts/background.ts | 28 ++++++---------------------- ts/types/Storage.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index fc62f734a57d..7e78cfa38daf 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -53,7 +53,7 @@ import * as KeyboardLayout from './services/keyboardLayout'; import * as StorageService from './services/storage'; import { usernameIntegrity } from './services/usernameIntegrity'; import { RoutineProfileRefresher } from './routineProfileRefresh'; -import { isOlderThan, toDayMillis } from './util/timestamp'; +import { isOlderThan } from './util/timestamp'; import { isValidReactionEmoji } from './reactions/isValidReactionEmoji'; import type { ConversationModel } from './models/conversations'; import { getContact, isIncoming } from './messages/helpers'; @@ -826,27 +826,6 @@ export async function startApp(): Promise { window.document.body.classList.remove('window-focused') ); - // How long since we were last running? - const lastHeartbeat = toDayMillis(window.storage.get('lastHeartbeat', 0)); - const previousLastStartup = window.storage.get('lastStartup'); - await window.storage.put('lastStartup', Date.now()); - - const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000; - if (lastHeartbeat > 0 && isOlderThan(lastHeartbeat, THIRTY_DAYS)) { - log.warn( - `This instance has not been used for 30 days. Last heartbeat: ${lastHeartbeat}. Last startup: ${previousLastStartup}.` - ); - await unlinkAndDisconnect(); - } - - // Start heartbeat timer - await window.storage.put('lastHeartbeat', toDayMillis(Date.now())); - const TWELVE_HOURS = 12 * 60 * 60 * 1000; - setInterval( - () => window.storage.put('lastHeartbeat', toDayMillis(Date.now())), - TWELVE_HOURS - ); - const currentVersion = window.getVersion(); lastVersion = window.storage.get('version'); newVersion = !lastVersion || currentVersion !== lastVersion; @@ -954,6 +933,11 @@ export async function startApp(): Promise { window.SignalContext.restartApp(); return; } + + if (window.isBeforeVersion(lastVersion, 'v7.3.0-beta.1')) { + await window.storage.remove('lastHeartbeat'); + await window.storage.remove('lastStartup'); + } } setAppLoadingScreenMessage( diff --git a/ts/types/Storage.d.ts b/ts/types/Storage.d.ts index 5ffd070e6708..8cd4c9c84ce2 100644 --- a/ts/types/Storage.d.ts +++ b/ts/types/Storage.d.ts @@ -77,8 +77,6 @@ export type StorageAccessType = { hasStoriesDisabled: boolean; storyViewReceiptsEnabled: boolean; identityKeyMap: IdentityKeyMap; - lastHeartbeat: number; - lastStartup: number; lastAttemptedToRefreshProfilesAt: number; lastResortKeyUpdateTime: number; lastResortKeyUpdateTimePNI: number; @@ -172,6 +170,8 @@ export type StorageAccessType = { senderCertificateWithUuid: never; signaling_key: never; signedKeyRotationRejected: number; + lastHeartbeat: never; + lastStartup: never; }; export type StorageInterface = {