mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-16 03:30:05 -05: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
1 changed files with 4 additions and 1 deletions
|
@ -686,6 +686,9 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
@returns {Discourse.Post} the post from the identity map
|
@returns {Discourse.Post} the post from the identity map
|
||||||
**/
|
**/
|
||||||
storePost: function(post) {
|
storePost: function(post) {
|
||||||
|
// Calling `Em.get(undefined` raises an error
|
||||||
|
if (!post) { return; }
|
||||||
|
|
||||||
var postId = Em.get(post, 'id');
|
var postId = Em.get(post, 'id');
|
||||||
if (postId) {
|
if (postId) {
|
||||||
var postIdentityMap = this.get('postIdentityMap'),
|
var postIdentityMap = this.get('postIdentityMap'),
|
||||||
|
@ -745,7 +748,7 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
return this.loadIntoIdentityMap(unloaded).then(function() {
|
return this.loadIntoIdentityMap(unloaded).then(function() {
|
||||||
return postIds.map(function (p) {
|
return postIds.map(function (p) {
|
||||||
return postIdentityMap.get(p);
|
return postIdentityMap.get(p);
|
||||||
});
|
}).compact();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue