More refactoring to reduce global event dependencies

All Whisper.events listeners are now defined and bound in background.js,
and we no longer need global methods for opening the inbox and
conversation views, as those are handled by AppView or internally by
InboxView.

// FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-09-01 11:30:41 -07:00
parent 8d32a3bebd
commit 601081c1b8
No known key found for this signature in database
GPG key ID: A4931C09644C654B
5 changed files with 12 additions and 27 deletions

View file

@ -87,13 +87,14 @@
appView.inboxView.networkStatusView.setSocketReconnectInterval(60000);
});
[
'openInbox',
'openInstaller',
'openConversation',
'openStandalone'
].forEach(function(eventName) {
appView.listenTo(Whisper.events, eventName, appView[eventName]);
Whisper.Notifications.on('click', function(conversation) {
if (conversation) {
appView.openConversation(conversation);
} else {
appView.openInbox({
initialLoadComplete: initialLoadComplete
});
}
});
});

View file

@ -20,13 +20,12 @@
this.on('remove', this.onRemove);
},
onclick: function() {
var conversation;
var last = this.last();
if (!last) {
openInbox();
return;
if (last) {
conversation = ConversationController.get(last.get('conversationId'));
}
var conversation = ConversationController.get(last.get('conversationId'));
openConversation(conversation);
this.trigger('click', conversation);
this.clear();
},
update: function() {

View file

@ -25,10 +25,6 @@
};
var inboxWindowId = 'inbox';
window.openInbox = function(options) {
Whisper.events.trigger('openInbox', options);
};
window.setUnreadCount = function(count) {
if (count > 0) {
window.setBadgeCount(count);
@ -39,8 +35,4 @@
}
};
window.openConversation = function(conversation) {
Whisper.events.trigger('openConversation', conversation);
};
})();

View file

@ -11,7 +11,6 @@
events: {
'click .openInstaller': 'openInstaller',
'click .openStandalone': 'openStandalone',
'openInstaller': 'openInstaller',
'openInbox': 'openInbox',
},
openView: function(view) {

View file

@ -25,12 +25,6 @@
this.model = new Backbone.Model();
this.listenTo(this.model, 'change', this.onChange);
},
events: {
'click .openInstaller': 'openInstaller'
},
openInstaller: function() {
this.$el.trigger('openInstaller');
},
onReconnectTimer: function() {
this.setSocketReconnectInterval(60000);
},