Extra safety to the post stream. Don't return undefined if we can't

retrieve a post for some reason.
This commit is contained in:
Robin Ward 2014-06-13 16:00:18 -04:00
parent 929a195c5d
commit 3c8a610f73

View File

@ -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();
});
},