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
pull/749/head
Scott Nonnenberg 8 years ago
parent 8d32a3bebd
commit 601081c1b8
No known key found for this signature in database
GPG Key ID: A4931C09644C654B

@ -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
});
}
});
});

@ -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() {

@ -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);
};
})();

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

@ -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);
},

Loading…
Cancel
Save