Fixing the elusive missing post bug

Этот коммит содержится в:
JoramWilander
2016-02-11 09:22:57 -05:00
родитель a15f8c582d
Коммит cac086ae22
2 изменённых файлов: 4 добавлений и 19 удалений

Просмотреть файл

@@ -83,8 +83,6 @@ class PostStoreClass extends EventEmitter {
this.getCommentDraft = this.getCommentDraft.bind(this); this.getCommentDraft = this.getCommentDraft.bind(this);
this.clearDraftUploads = this.clearDraftUploads.bind(this); this.clearDraftUploads = this.clearDraftUploads.bind(this);
this.clearCommentDraftUploads = this.clearCommentDraftUploads.bind(this); this.clearCommentDraftUploads = this.clearCommentDraftUploads.bind(this);
this.storeLatestUpdate = this.storeLatestUpdate.bind(this);
this.getLatestUpdate = this.getLatestUpdate.bind(this);
this.getCurrentUsersLatestPost = this.getCurrentUsersLatestPost.bind(this); this.getCurrentUsersLatestPost = this.getCurrentUsersLatestPost.bind(this);
this.getCommentCount = this.getCommentCount.bind(this); this.getCommentCount = this.getCommentCount.bind(this);
@@ -258,7 +256,7 @@ class PostStoreClass extends EventEmitter {
const np = newPosts.posts[pid]; const np = newPosts.posts[pid];
if (np.delete_at === 0) { if (np.delete_at === 0) {
combinedPosts.posts[pid] = np; combinedPosts.posts[pid] = np;
if (combinedPosts.order.indexOf(pid) === -1) { if (combinedPosts.order.indexOf(pid) === -1 && newPosts.order.indexOf(pid) !== -1) {
combinedPosts.order.push(pid); combinedPosts.order.push(pid);
} }
} }
@@ -507,19 +505,6 @@ class PostStoreClass extends EventEmitter {
} }
}); });
} }
storeLatestUpdate(channelId, time) {
if (!this.postsInfo.hasOwnProperty(channelId)) {
this.postsInfo[channelId] = {};
}
this.postsInfo[channelId].latestPost = time;
}
getLatestUpdate(channelId) {
if (this.postsInfo.hasOwnProperty(channelId) && this.postsInfo[channelId].hasOwnProperty('latestPost')) {
return this.postsInfo[channelId].latestPost;
}
return 0;
}
getCommentCount(post) { getCommentCount(post) {
const posts = this.getAllPosts(post.channel_id).posts; const posts = this.getAllPosts(post.channel_id).posts;

Просмотреть файл

@@ -521,18 +521,18 @@ export function getPosts(id) {
return; return;
} }
if (PostStore.getAllPosts(channelId) == null) { if ($.isEmptyObject(PostStore.getAllPosts(channelId))) {
getPostsPage(channelId, Constants.POST_CHUNK_SIZE); getPostsPage(channelId, Constants.POST_CHUNK_SIZE);
return; return;
} }
const latestUpdate = PostStore.getLatestUpdate(channelId); const latestPost = PostStore.getLatestPost(channelId);
callTracker['getPosts_' + channelId] = utils.getTimestamp(); callTracker['getPosts_' + channelId] = utils.getTimestamp();
client.getPosts( client.getPosts(
channelId, channelId,
latestUpdate, latestPost.update_at,
(data, textStatus, xhr) => { (data, textStatus, xhr) => {
if (xhr.status === 304 || !data) { if (xhr.status === 304 || !data) {
return; return;