From 40af226a4a37ac69c3340d82f2c4e9c19a9417ed Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 21 Apr 2017 13:21:18 -0700 Subject: [PATCH] Move Whisper.events out of views and tests --- js/background.js | 11 +++++++++++ js/options.js | 2 ++ js/views/install_view.js | 2 -- js/views/network_status_view.js | 2 -- test/_test.js | 1 - test/test.js | 1 - 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index 1f7e523e5..05052be41 100644 --- a/js/background.js +++ b/js/background.js @@ -324,5 +324,16 @@ } }; + Whisper.events.on('unauthorized', function() { + if (owsDesktopApp.inboxView) { + owsDesktopApp.inboxView.networkStatusView.update(); + } + }); + Whisper.events.on('reconnectTimer', function() { + if (owsDesktopApp.inboxView) { + owsDesktopApp.inboxView.networkStatusView.setSocketReconnectInterval(60000); + } + }); + })(); diff --git a/js/options.js b/js/options.js index 7605142fe..606d63ac5 100644 --- a/js/options.js +++ b/js/options.js @@ -15,7 +15,9 @@ installView.hideDots(); } installView.$el.show(); + Whisper.events.on('contactsync:begin', installView.showSync, installView); Whisper.events.on('contactsync', function() { + installView.close(); bg.openInbox(); window.close(); }); diff --git a/js/views/install_view.js b/js/views/install_view.js index eb34a4dd5..125209656 100644 --- a/js/views/install_view.js +++ b/js/views/install_view.js @@ -49,8 +49,6 @@ this.$('#step1').show(); this.connect(); this.on('disconnected', this.reconnect); - this.listenTo(Whisper.events, 'contactsync:begin', this.showSync); - this.listenTo(Whisper.events, 'contactsync', this.close); }, connect: function() { this.clearQR(); diff --git a/js/views/network_status_view.js b/js/views/network_status_view.js index 93e4fb851..88b93494a 100644 --- a/js/views/network_status_view.js +++ b/js/views/network_status_view.js @@ -19,8 +19,6 @@ window.addEventListener('online', this.update.bind(this)); window.addEventListener('offline', this.update.bind(this)); - Whisper.events.on('unauthorized', this.update, this); - Whisper.events.on('reconnectTimer', this.onReconnectTimer, this); this.model = new Backbone.Model(); this.listenTo(this.model, 'change', this.onChange); diff --git a/test/_test.js b/test/_test.js index bd093e8ab..119c07aa4 100644 --- a/test/_test.js +++ b/test/_test.js @@ -45,7 +45,6 @@ window.assert = chai.assert; window.Whisper = window.Whisper || {}; window.Whisper.Database = window.Whisper.Database || {}; Whisper.Database.id = 'test'; -Whisper.events = _.clone(Backbone.Events); /* * global helpers for tests diff --git a/test/test.js b/test/test.js index 16a130860..99daff403 100644 --- a/test/test.js +++ b/test/test.js @@ -12257,7 +12257,6 @@ window.assert = chai.assert; window.Whisper = window.Whisper || {}; window.Whisper.Database = window.Whisper.Database || {}; Whisper.Database.id = 'test'; -Whisper.events = _.clone(Backbone.Events); /* * global helpers for tests