summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-02-11 13:45:52 -0500
committerChristopher Speller <crspeller@gmail.com>2016-02-11 13:45:52 -0500
commit50104a1aa8827bd6f25a1ef64fc3ff807071e29d (patch)
tree71b2ebc4aac7d8778f05c6ca9e56cde051855385 /web
parent8eca7b14177fc8652ba1fbbf1f8ab3b0adee4c31 (diff)
parent3a1ec7dbd76ecad556cca0cee54f574bf813c1fd (diff)
downloadchat-50104a1aa8827bd6f25a1ef64fc3ff807071e29d.tar.gz
chat-50104a1aa8827bd6f25a1ef64fc3ff807071e29d.tar.bz2
chat-50104a1aa8827bd6f25a1ef64fc3ff807071e29d.zip
Merge pull request #2148 from mattermost/missing-posts-2.0
RC2 PLT-1774 Fixing the elusive missing post bug
Diffstat (limited to 'web')
-rw-r--r--web/react/stores/post_store.jsx17
-rw-r--r--web/react/utils/async_client.jsx13
2 files changed, 11 insertions, 19 deletions
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index b5bb93576..f5c342163 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -83,8 +83,6 @@ class PostStoreClass extends EventEmitter {
this.getCommentDraft = this.getCommentDraft.bind(this);
this.clearDraftUploads = this.clearDraftUploads.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.getCommentCount = this.getCommentCount.bind(this);
@@ -258,7 +256,7 @@ class PostStoreClass extends EventEmitter {
const np = newPosts.posts[pid];
if (np.delete_at === 0) {
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);
}
}
@@ -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) {
const posts = this.getAllPosts(post.channel_id).posts;
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index c8676f45d..45cdf699f 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -521,18 +521,25 @@ export function getPosts(id) {
return;
}
- if (PostStore.getAllPosts(channelId) == null) {
+ const postList = PostStore.getAllPosts(channelId);
+
+ if ($.isEmptyObject(postList) || postList.order.length < Constants.POST_CHUNK_SIZE) {
getPostsPage(channelId, Constants.POST_CHUNK_SIZE);
return;
}
- const latestUpdate = PostStore.getLatestUpdate(channelId);
+ const latestPost = PostStore.getLatestPost(channelId);
+ let latestPostTime = 0;
+
+ if (latestPost != null && latestPost.update_at != null) {
+ latestPostTime = latestPost.create_at;
+ }
callTracker['getPosts_' + channelId] = utils.getTimestamp();
client.getPosts(
channelId,
- latestUpdate,
+ latestPostTime,
(data, textStatus, xhr) => {
if (xhr.status === 304 || !data) {
return;