diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 510d9e5cfa..5ca8354f72 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -12,7 +12,7 @@ var conversations = new Whisper.ConversationCollection(); var inboxCollection = new (Backbone.Collection.extend({ initialize: function() { - this.on('change:active_at', this.sort); + this.on('change:timestamp change:name change:number', this.sort); this.on('add remove change:unreadCount', this.updateUnreadCount); this.listenTo(conversations, 'add change:active_at', this.addActive); diff --git a/js/models/conversations.js b/js/models/conversations.js index 2897aceffb..1e35a65aef 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -283,7 +283,7 @@ var models = this.messageCollection.models; this.messageCollection.reset([]); _.each(models, function(message) { message.destroy(); }); - this.save({active_at: null, lastMessage: '', timestamp: null}); // archive + this.save({lastMessage: null, timestamp: null}); // archive }.bind(this)); }, diff --git a/js/views/conversation_list_view.js b/js/views/conversation_list_view.js index e594f152ce..0fd3374c1f 100644 --- a/js/views/conversation_list_view.js +++ b/js/views/conversation_list_view.js @@ -8,14 +8,15 @@ Whisper.ConversationListView = Whisper.ListView.extend({ tagName: 'div', itemView: Whisper.ConversationListItemView, - onChangeActiveAt: function(conversation) { + sort: function(conversation) { + console.log('sorting conversation', conversation.id); var $el = this.$('.' + conversation.cid); if ($el && $el.length > 0) { - if (conversation.get('active_at')) { - $el.prependTo(this.el); - } else { - var index = getInboxCollection().indexOf(conversation); + var index = getInboxCollection().indexOf(conversation); + if (index > 0) { $el.insertBefore(this.$('.conversation-list-item')[index+1]); + } else { + this.$el.prepend($el); } } } diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 758111c8f6..abb9e789ef 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -68,8 +68,8 @@ }).render(); this.inboxListView.listenTo(inboxCollection, - 'add change:active_at', - this.inboxListView.onChangeActiveAt); + 'add change:timestamp change:name change:number', + this.inboxListView.sort); this.searchView = new Whisper.ConversationSearchView({ el : this.$('.search-results'),