From a390e37abc29fee7a96b89003c552ed047c40706 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 14 Sep 2015 16:28:27 -0700 Subject: [PATCH] Fixup change:active_at handling when setting null When a conversation goes from active to not active, it should be removed the view rather than promoted. // FREEBIE --- js/views/conversation_list_view.js | 8 ++++++-- js/views/inbox_view.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/views/conversation_list_view.js b/js/views/conversation_list_view.js index 64368109a..1692cf0ca 100644 --- a/js/views/conversation_list_view.js +++ b/js/views/conversation_list_view.js @@ -8,10 +8,14 @@ Whisper.ConversationListView = Whisper.ListView.extend({ tagName: 'div', itemView: Whisper.ConversationListItemView, - moveToTop: function(conversation) { + onChangeActiveAt: function(conversation) { var $el = this.$('.' + conversation.cid); if ($el && $el.length > 0) { - $el.prependTo(this.el); + if (conversation.get('active_at')) { + $el.prependTo(this.el); + } else { + $el.remove(); + } } } }); diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index d4ae0304e..9d761fcd1 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -87,17 +87,17 @@ this.openConversation.bind(this, null)); var inboxCollection = bg.getInboxCollection(); - this.inboxView = new Whisper.ConversationListView({ + this.inboxListView = new Whisper.ConversationListView({ el : this.$('.conversations'), collection : inboxCollection }).render(); - this.inboxView.listenTo(inboxCollection, 'change:active_at', this.inboxView.moveToTop); + this.inboxListView.listenTo(inboxCollection, 'change:active_at', this.inboxListView.onChangeActiveAt); new SocketView().render().$el.appendTo(this.$('.socket-status')); extension.windows.beforeUnload(function() { - this.inboxView.stopListening(); + this.inboxListView.stopListening(); }.bind(this)); new Whisper.WindowControlsView({