diff --git a/js/modules/refresh_sender_certificate.js b/js/modules/refresh_sender_certificate.js index a25f10d3e..275453fda 100644 --- a/js/modules/refresh_sender_certificate.js +++ b/js/modules/refresh_sender_certificate.js @@ -7,9 +7,9 @@ module.exports = { const ONE_DAY = 24 * 60 * 60 * 1000; // one day const MINIMUM_TIME_LEFT = 2 * 60 * 60 * 1000; // two hours -let initialized = false; let timeout = null; let scheduledTime = null; +let scheduleNext = null; // We need to refresh our own profile regularly to account for newly-added devices which // do not support unidentified delivery. @@ -20,19 +20,16 @@ function refreshOurProfile() { } function initialize({ events, storage, navigator, logger }) { - if (initialized) { - logger.warn('refreshSenderCertificate: already initialized!'); + // We don't want to set up all of the below functions, but we do want to ensure that our + // refresh timer is up-to-date. + if (scheduleNext) { + scheduleNext(); return; } - initialized = true; runWhenOnline(); - events.on('timetravel', () => { - if (initialized) { - scheduleNextRotation(); - } - }); + events.on('timetravel', scheduleNextRotation); function scheduleNextRotation() { const now = Date.now(); @@ -55,6 +52,9 @@ function initialize({ events, storage, navigator, logger }) { setTimeoutForNextRun(time); } + // Keeping this entrypoint around so more inialize() calls just kick the timing + scheduleNext = scheduleNextRotation; + async function run() { logger.info('refreshSenderCertificate: Getting new certificate...'); try { diff --git a/package.json b/package.json index c3a2d4e59..c9832acf3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "Loki Messenger", "description": "Private messaging from your desktop", "repository": "https://github.com/sloki-project/loki-messenger.git", - "version": "1.17.0", + "version": "1.18.0", "license": "GPL-3.0", "author": { "name": "Open Whisper Systems",