Skip to content

Commit

Permalink
Remove conversation from left pane on 'delete messages' (#1807)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg authored Nov 22, 2017
1 parent abb83a8 commit 87d8ec7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 8 additions & 2 deletions js/models/conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,14 @@
}).then(function() {
var models = this.messageCollection.models;
this.messageCollection.reset([]);
_.each(models, function(message) { message.destroy(); });
this.save({lastMessage: null, timestamp: null}); // archive
_.each(models, function(message) {
message.destroy();
});
this.save({
lastMessage: null,
timestamp: null,
active_at: null,
});
}.bind(this));
},

Expand Down
6 changes: 6 additions & 0 deletions js/views/conversation_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
$el.insertBefore(target);
}
}
},
removeItem: function(conversation) {
var $el = this.$('.' + conversation.cid);
if ($el && $el.length > 0) {
$el.remove();
}
}
});
})();
13 changes: 10 additions & 3 deletions js/views/inbox_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,16 @@
collection : inboxCollection
}).render();

this.inboxListView.listenTo(inboxCollection,
'add change:timestamp change:name change:number',
this.inboxListView.updateLocation);
this.inboxListView.listenTo(
inboxCollection,
'add change:timestamp change:name change:number',
this.inboxListView.updateLocation
);
this.inboxListView.listenTo(
inboxCollection,
'remove',
this.inboxListView.removeItem
);

this.searchView = new Whisper.ConversationSearchView({
el : this.$('.search-results'),
Expand Down

0 comments on commit 87d8ec7

Please sign in to comment.