update formatting in post_store
Этот коммит содержится в:
@@ -104,59 +104,71 @@ var PostStore = assign({}, EventEmitter.prototype, {
|
|||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
storePendingPost: function(post) {
|
storePendingPost: function(post) {
|
||||||
var post_list = this.getPendingPosts(post.channel_id);
|
var postList = this.getPendingPosts(post.channel_id);
|
||||||
if (!post_list) {
|
if (!postList) {
|
||||||
post_list = {posts: {}, order: []};
|
postList = {posts: {}, order: []};
|
||||||
}
|
}
|
||||||
|
|
||||||
post_list.posts[post.pending_post_id] = post;
|
postList.posts[post.pending_post_id] = post;
|
||||||
post_list.order.unshift(post.pending_post_id);
|
postList.order.unshift(post.pending_post_id);
|
||||||
this._storePendingPosts(post.channel_id, post_list);
|
this._storePendingPosts(post.channel_id, postList);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
_storePendingPosts: function(channelId, posts) {
|
_storePendingPosts: function(channelId, posts) {
|
||||||
BrowserStore.setItem("pending_posts_" + channelId, posts);
|
BrowserStore.setItem('pending_posts_' + channelId, posts);
|
||||||
},
|
},
|
||||||
getPendingPosts: function(channelId) {
|
getPendingPosts: function(channelId) {
|
||||||
return BrowserStore.getItem("pending_posts_" + channelId);
|
return BrowserStore.getItem('pending_posts_' + channelId);
|
||||||
},
|
},
|
||||||
removePendingPost: function(channelId, pending_post_id) {
|
removePendingPost: function(channelId, pendingPostId) {
|
||||||
this._removePendingPost(channelId, pending_post_id);
|
this._removePendingPost(channelId, pendingPostId);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
_removePendingPost: function(channelId, pending_post_id) {
|
_removePendingPost: function(channelId, pendingPostId) {
|
||||||
var post_list = this.getPendingPosts(channelId);
|
var postList = this.getPendingPosts(channelId);
|
||||||
if (!post_list) return;
|
if (!postList) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pending_post_id in post_list.posts) delete post_list.posts[pending_post_id];
|
if (pendingPostId in postList.posts) {
|
||||||
var index = post_list.order.indexOf(pending_post_id);
|
delete postList.posts[pendingPostId];
|
||||||
if (index >= 0) post_list.order.splice(index, 1);
|
}
|
||||||
|
var index = postList.order.indexOf(pendingPostId);
|
||||||
|
if (index >= 0) {
|
||||||
|
postList.order.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
this._storePendingPosts(channelId, post_list);
|
this._storePendingPosts(channelId, postList);
|
||||||
},
|
},
|
||||||
clearPendingPosts: function(channelId) {
|
clearPendingPosts: function(channelId) {
|
||||||
BrowserStore.removeItem("pending_posts_" + channelId)
|
BrowserStore.removeItem('pending_posts_' + channelId);
|
||||||
},
|
},
|
||||||
removeNonFailedPendingPosts: function(channelId) {
|
removeNonFailedPendingPosts: function(channelId) {
|
||||||
var post_list = this.getPendingPosts(channelId);
|
var postList = this.getPendingPosts(channelId);
|
||||||
if (!post_list) return;
|
if (!postList) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var posts = post_list.posts;
|
var posts = postList.posts;
|
||||||
|
|
||||||
for (var id in posts) {
|
for (var id in posts) {
|
||||||
if (!posts[id].did_fail) this._removePendingPost(channelId, id);
|
if (!posts[id].did_fail) {
|
||||||
|
this._removePendingPost(channelId, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updatePendingPost: function(post) {
|
updatePendingPost: function(post) {
|
||||||
var post_list = this.getPendingPosts(post.channel_id);
|
var postList = this.getPendingPosts(post.channel_id);
|
||||||
if (!post_list) {
|
if (!postList) {
|
||||||
post_list = {posts: {}, order: []};
|
postList = {posts: {}, order: []};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post_list.order.indexOf(post.pending_post_id) === -1) return;
|
if (postList.order.indexOf(post.pending_post_id) === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
post_list.posts[post.pending_post_id] = post;
|
postList.posts[post.pending_post_id] = post;
|
||||||
this._storePendingPosts(post.channel_id, post_list);
|
this._storePendingPosts(post.channel_id, postList);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
pStorePosts: function pStorePosts(channelId, posts) {
|
pStorePosts: function pStorePosts(channelId, posts) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user