mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
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:
parent
929a195c5d
commit
3c8a610f73
@ -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();
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user