From 3c8a610f73096998788c8a288a20acb206878fdb Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 13 Jun 2014 16:00:18 -0400 Subject: [PATCH] Extra safety to the post stream. Don't return `undefined` if we can't retrieve a post for some reason. --- app/assets/javascripts/discourse/models/post_stream.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/models/post_stream.js b/app/assets/javascripts/discourse/models/post_stream.js index 0a38c5c8d..54d9b3e94 100644 --- a/app/assets/javascripts/discourse/models/post_stream.js +++ b/app/assets/javascripts/discourse/models/post_stream.js @@ -686,6 +686,9 @@ Discourse.PostStream = Em.Object.extend({ @returns {Discourse.Post} the post from the identity map **/ storePost: function(post) { + // Calling `Em.get(undefined` raises an error + if (!post) { return; } + var postId = Em.get(post, 'id'); if (postId) { var postIdentityMap = this.get('postIdentityMap'), @@ -745,7 +748,7 @@ Discourse.PostStream = Em.Object.extend({ return this.loadIntoIdentityMap(unloaded).then(function() { return postIds.map(function (p) { return postIdentityMap.get(p); - }); + }).compact(); }); },