From 510a5cb7fe9267aed4cf0811143db389bf82285d Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 12 Apr 2017 13:31:50 -0700 Subject: [PATCH] Namespace global listeners to Whisper --- js/background.js | 6 +++--- js/expiring_messages.js | 2 +- js/models/messages.js | 2 +- js/rotate_signed_prekey_listener.js | 3 ++- js/wall_clock_listener.js | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/background.js b/js/background.js index c9bf09057be0..e907a8c87dc2 100644 --- a/js/background.js +++ b/js/background.js @@ -86,9 +86,9 @@ openInbox(); } - WallClockListener.init(); - RotateSignedPreKeyListener.init(); - ExpiringMessagesListener.init(); + Whisper.WallClockListener.init(); + Whisper.RotateSignedPreKeyListener.init(); + Whisper.ExpiringMessagesListener.init(); }); window.getSyncRequest = function() { diff --git a/js/expiring_messages.js b/js/expiring_messages.js index 0d96b5a62a9a..5220a45dfe31 100644 --- a/js/expiring_messages.js +++ b/js/expiring_messages.js @@ -36,7 +36,7 @@ expiring.fetchNextExpiring(); } - window.ExpiringMessagesListener = { + Whisper.ExpiringMessagesListener = { init: function() { checkExpiringMessages(); window.events.on('timetravel', checkExpiringMessages); diff --git a/js/models/messages.js b/js/models/messages.js index 431fa4a7a49d..a685a45b5c08 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -481,7 +481,7 @@ var delta = this.get('expireTimer') * 1000; var expires_at = start + delta; this.save('expires_at', expires_at); - ExpiringMessagesListener.update(); + Whisper.ExpiringMessagesListener.update(); console.log('message', this.get('sent_at'), 'expires at', expires_at); } } diff --git a/js/rotate_signed_prekey_listener.js b/js/rotate_signed_prekey_listener.js index d39349b797a5..998b1663ddcb 100644 --- a/js/rotate_signed_prekey_listener.js +++ b/js/rotate_signed_prekey_listener.js @@ -4,6 +4,7 @@ ;(function () { 'use strict'; + window.Whisper = window.Whisper || {}; var ROTATION_INTERVAL = 48 * 60 * 60 * 1000; var timeout; @@ -44,7 +45,7 @@ timeout = setTimeout(runWhenOnline, waitTime); } - window.RotateSignedPreKeyListener = { + Whisper.RotateSignedPreKeyListener = { init: function() { if (Whisper.Registration.isDone()) { setTimeoutForNextRun(); diff --git a/js/wall_clock_listener.js b/js/wall_clock_listener.js index cf25da58a1c5..a602a67271bd 100644 --- a/js/wall_clock_listener.js +++ b/js/wall_clock_listener.js @@ -4,6 +4,7 @@ ;(function () { 'use strict'; + window.Whisper = window.Whisper || {}; var lastTime; var interval = 1000; @@ -16,7 +17,7 @@ lastTime = currentTime; } - window.WallClockListener = { + Whisper.WallClockListener = { init: function() { lastTime = Date.now(); setInterval(checkTime, 1000);