Avoid excessive re-rendering of the inbox list
This listener is doing way more work than necessary to update the dom by removing all the list items and re-creating them. This also causes the bug where selected state is cleared when new messages arrive, not to mention binding new event listeners without unbinding the old ones. Fix by simply promoting an element to the top of the list when it's active_at value changes, rather than re-rendering the whole list. This could backfire if the value gets changed to an earlier timestamp but for now we assume that won't happen. // FREEBIE
This commit is contained in:
parent
e80fa187ba
commit
bd5f43bdb1
3 changed files with 10 additions and 2 deletions
|
@ -92,7 +92,7 @@
|
|||
collection : inboxCollection
|
||||
}).render();
|
||||
|
||||
this.inboxView.listenTo(inboxCollection, 'sort', this.inboxView.render);
|
||||
this.inboxView.listenTo(inboxCollection, 'change:active_at', this.inboxView.moveToTop);
|
||||
|
||||
new SocketView().render().$el.appendTo(this.$('.socket-status'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue