diff --git a/js/background.js b/js/background.js index 204c5afdd..0d5a92f1c 100644 --- a/js/background.js +++ b/js/background.js @@ -65,7 +65,7 @@ init(true); }); - var appView = window.owsDesktopApp.appView = new Whisper.AppView({el: $('body'), events: Whisper.events}); + var appView = window.owsDesktopApp.appView = new Whisper.AppView({el: $('body')}); Whisper.WallClockListener.init(Whisper.events); Whisper.RotateSignedPreKeyListener.init(Whisper.events); @@ -87,6 +87,14 @@ appView.inboxView.networkStatusView.setSocketReconnectInterval(60000); }); + [ + 'openInbox', + 'openInstaller', + 'openConversation', + 'openStandalone' + ].forEach(function(eventName) { + appView.listenTo(Whisper.events, eventName, appView[eventName]); + }); }); window.getSyncRequest = function() { diff --git a/js/views/app_view.js b/js/views/app_view.js index b2bf4a6cc..a1f0d659d 100644 --- a/js/views/app_view.js +++ b/js/views/app_view.js @@ -7,15 +7,15 @@ initialize: function(options) { this.inboxView = null; this.installView = null; - this.events = options.events; - this.events.on('openStandalone', this.openStandaloneInstaller, this); - this.events.on('openConversation', this.openConversation, this); - this.events.on('openInstaller', this.openInstaller, this); - this.events.on('openInbox', this.openInbox, this); + }, + events: { + 'openInstaller': 'openInstaller', + 'openInbox': 'openInbox', }, openView: function(view) { this.el.innerHTML = ""; this.el.append(view.el); + this.delegateEvents(); }, openInstaller: function() { this.closeInstaller(); @@ -26,10 +26,12 @@ } this.openView(this.installView); }, - openStandaloneInstaller: function() { - this.closeInstaller(); - this.installView = new Whisper.StandaloneRegistrationView(); - this.openView(this.installView); + openStandalone: function() { + if (window.config.environment !== 'production') { + this.closeInstaller(); + this.installView = new Whisper.StandaloneRegistrationView(); + this.openView(this.installView); + } }, closeInstaller: function() { if (this.installView) { diff --git a/js/views/network_status_view.js b/js/views/network_status_view.js index 55689b233..1b948e6f5 100644 --- a/js/views/network_status_view.js +++ b/js/views/network_status_view.js @@ -29,7 +29,7 @@ 'click .openInstaller': 'openInstaller' }, openInstaller: function() { - Whisper.events.trigger('openInstaller'); + this.$el.trigger('openInstaller'); }, onReconnectTimer: function() { this.setSocketReconnectInterval(60000); diff --git a/js/views/standalone_registration_view.js b/js/views/standalone_registration_view.js index eab7723ed..b3cbb94d8 100644 --- a/js/views/standalone_registration_view.js +++ b/js/views/standalone_registration_view.js @@ -32,8 +32,8 @@ var verificationCode = $('#code').val().replace(/\D+/g, ""); this.accountManager.registerSingleDevice(number, verificationCode).then(function() { - Whisper.events.trigger('openInbox'); - }).catch(this.log.bind(this)); + this.$el.trigger('openInbox'); + }.bind(this)).catch(this.log.bind(this)); }, log: function (s) { console.log(s);