Clean up open-event logic with new convos and search results

Search view triggers an open event when a valid phone number is entered
and the 'Create new contact' card is clicked.

Inbox view should listen and respond to this event. It should also
disregard select events on the new contact element since those are fired
before phone number validation.

Finally, the search view can stop listening to select events because the
inbox view is already doing so.

// FREEBIE
This commit is contained in:
lilia 2015-12-01 16:13:58 -08:00
parent af64784d64
commit ae52c047bf
2 changed files with 4 additions and 7 deletions

View file

@ -26,7 +26,6 @@
events: {
'select .new-contact': 'createConversation',
'select .contacts': 'open'
},
filterContacts: function(e) {
@ -72,17 +71,13 @@
ConversationController.findOrCreatePrivateById(
this.new_contact_view.model.id
).then(function(conversation) {
this.$el.trigger('open', conversation);
this.trigger('open', conversation);
this.initNewContact();
this.resetTypeahead();
}.bind(this));
}
},
open: function(e, conversation) {
this.$el.trigger('open', conversation);
},
reset: function() {
this.delegateEvents();
this.typeahead_view.delegateEvents();

View file

@ -98,6 +98,8 @@
this.searchView.$el.show();
this.inboxListView.$el.hide();
});
this.listenTo(this.searchView, 'open',
this.openConversation.bind(this, null));
if (inboxCollection.length === 0) {
this.searchView.showAllContacts = true;
@ -120,7 +122,7 @@
'click .hamburger': 'toggleMenu',
'click .show-debug-log': 'showDebugLog',
'click .show-new-conversation': 'showCompose',
'select .gutter .contact': 'openConversation',
'select .gutter .conversation-list-item': 'openConversation',
'input input.search': 'filterContacts'
},
filterContacts: function(e) {