Fix conversation list self-resorting
When deleting all messages in a conversation, the entry in the left pane should be inserted into the alphabetical portion of the list. To keep it in this collection, do not nullify active_at. To ensure the list view is keeping itself correctly sorted, make sure that resorting behavior is triggered any time a relevant attribute is changed. This fixes deleted conversations jumping to the top of the list, and conversation order scrambling when getting a group or contact sync message from our master device. Fixes #734 // FREEBIE
This commit is contained in:
parent
7210636b5e
commit
07a0463b65
4 changed files with 10 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
},
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in a new issue