Don't make a new collection on every call to thread.messages()

This commit is contained in:
lilia 2014-07-22 08:46:36 -10:00
parent 7e20838128
commit 6d5e32bca8

View file

@ -40,9 +40,11 @@ var Whisper = Whisper || {};
}, },
messages: function() { messages: function() {
var messages = new Whisper.MessageCollection([], {threadId: this.id}); if (!this.messageCollection) {
messages.fetch(); this.messageCollection = new Whisper.MessageCollection([], {threadId: this.id});
return messages; }
this.messageCollection.fetch();
return this.messageCollection;
}, },
}); });