Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deselect conversation *FREEBIE* #1904

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions js/views/conversation_list_item_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
this.listenTo(this.model, 'change', _.debounce(this.render.bind(this), 1000));
this.listenTo(this.model, 'destroy', this.remove); // auto update
this.listenTo(this.model, 'opened', this.markSelected); // auto update
this.listenTo(this.model, 'closed', this.unmarkSelected);

var updateLastMessage = _.debounce(this.model.updateLastMessage.bind(this.model), 1000);
this.listenTo(this.model.messageCollection, 'add remove', updateLastMessage);
Expand All @@ -36,6 +37,12 @@
this.$el.addClass('selected').siblings('.selected').removeClass('selected');
},

unmarkSelected: function() {
// Similar to markSelected, this is necessary to remove the selection
// from the conversation list item after closing the conversation
this.$el.removeClass('selected');
},

select: function(e) {
this.markSelected();
this.$el.trigger('select', this.model);
Expand Down
43 changes: 43 additions & 0 deletions js/views/inbox_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
$el.prependTo(this.el);
conversation.trigger('opened');
}
// Add current to the selected id
this.selected_id = conversation.id;
},
close: function(conversation) {
var id = 'conversation-' + conversation.cid;
if (id === this.el.firstChild.id) {
// Remove the conversation-stack DIV and call the closed event
// from ConversationListItemView
// this.el.firstChild.remove();
this.$('.placeholder').prependTo(this.el);
conversation.trigger('closed');
}
// Update the selected_id member in order to avoid to further close
// the placeholder
this.selected_id = null;
}
});

Expand Down Expand Up @@ -167,6 +182,7 @@
'input input.search': 'filterContacts',
'click .restart-signal': window.restart,
'show .lightbox': 'showLightbox',
'keydown': 'closeConversation',
},
startConnectionListener: function() {
this.interval = setInterval(function() {
Expand Down Expand Up @@ -240,11 +256,38 @@
openConversation: function(e, conversation) {
this.searchView.hideHints();
if (conversation) {
var curr_id = this.conversation_stack.selected_id;
if (typeof curr_id !== 'undefined' && curr_id !== null) {
// If selecting the active conversation, don't do anything
if (curr_id == conversation.id) {
this.focusConversation();
return;
}
}
conversation = ConversationController.get(conversation.id);
this.conversation_stack.open(conversation);
this.focusConversation();
}
},
closeConversation: function(e) {
// This is triggered by shift + ESC
if (!e.shiftKey) {
return;
}
var keyCode = e.which || e.keyCode;
var curr_id = this.conversation_stack.selected_id;
// If no conversation is selected, return
if (curr_id === null || typeof curr_id === 'undefined') {
return;
}
var conversation = ConversationController.get(curr_id);
if (keyCode === 27) {
// Close the currently active conversation
this.conversation_stack.close(conversation);
this.$('#header, .gutter').addClass('inactive');
this.$('.conversation-stack').addClass('inactive');
}
},
toggleMenu: function() {
this.$('.global-menu .menu-list').toggle();
},
Expand Down