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
1 changed files with 5 additions and 3 deletions

View File

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