From 6d5e32bca8394b6bc15431b88666cc3181d99fc7 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 22 Jul 2014 08:46:36 -1000 Subject: [PATCH] Don't make a new collection on every call to thread.messages() --- js/models/threads.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/models/threads.js b/js/models/threads.js index 5f5bdb785..66acaf7bc 100644 --- a/js/models/threads.js +++ b/js/models/threads.js @@ -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; }, });