summaryrefslogtreecommitdiffstats
path: root/web/react/stores
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/stores')
-rw-r--r--web/react/stores/channel_store.jsx4
-rw-r--r--web/react/stores/post_store.jsx22
-rw-r--r--web/react/stores/socket_store.jsx4
3 files changed, 17 insertions, 13 deletions
diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx
index d650b23c2..ac800a988 100644
--- a/web/react/stores/channel_store.jsx
+++ b/web/react/stores/channel_store.jsx
@@ -308,7 +308,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.storeChannels(action.channels);
ChannelStore.storeChannelMembers(action.members);
currentId = ChannelStore.getCurrentId();
- if (currentId) {
+ if (currentId && !document.hidden) {
ChannelStore.resetCounts(currentId);
}
ChannelStore.setUnreadCounts();
@@ -321,7 +321,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.pStoreChannelMember(action.member);
}
currentId = ChannelStore.getCurrentId();
- if (currentId) {
+ if (currentId && !document.hidden) {
ChannelStore.resetCounts(currentId);
}
ChannelStore.setUnreadCount(action.channel.id);
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index b0f421b60..b5bb93576 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -376,15 +376,16 @@ class PostStoreClass extends EventEmitter {
}
storePendingPost(post) {
- post.state = Constants.POST_LOADING;
+ const copyPost = JSON.parse(JSON.stringify(post));
+ copyPost.state = Constants.POST_LOADING;
- const postList = makePostListNonNull(this.getPendingPosts(post.channel_id));
+ const postList = makePostListNonNull(this.getPendingPosts(copyPost.channel_id));
- postList.posts[post.pending_post_id] = post;
- postList.order.unshift(post.pending_post_id);
+ postList.posts[copyPost.pending_post_id] = copyPost;
+ postList.order.unshift(copyPost.pending_post_id);
- this.makePostsInfo(post.channel_id);
- this.postsInfo[post.channel_id].pendingPosts = postList;
+ this.makePostsInfo(copyPost.channel_id);
+ this.postsInfo[copyPost.channel_id].pendingPosts = postList;
this.emitChange();
}
@@ -410,14 +411,15 @@ class PostStoreClass extends EventEmitter {
}
updatePendingPost(post) {
- const postList = makePostListNonNull(this.getPendingPosts(post.channel_id));
+ const copyPost = JSON.parse(JSON.stringify(post));
+ const postList = makePostListNonNull(this.getPendingPosts(copyPost.channel_id));
- if (postList.order.indexOf(post.pending_post_id) === -1) {
+ if (postList.order.indexOf(copyPost.pending_post_id) === -1) {
return;
}
- postList.posts[post.pending_post_id] = post;
- this.postsInfo[post.channel_id].pendingPosts = postList;
+ postList.posts[copyPost.pending_post_id] = copyPost;
+ this.postsInfo[copyPost.channel_id].pendingPosts = postList;
this.emitChange();
}
diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx
index bc2bdbe64..e1b65fe14 100644
--- a/web/react/stores/socket_store.jsx
+++ b/web/react/stores/socket_store.jsx
@@ -188,7 +188,9 @@ function handleNewPostEvent(msg, translations) {
// Update channel state
if (ChannelStore.getCurrentId() === msg.channel_id) {
- if (window.isActive) {
+ if (document.hidden) {
+ AsyncClient.getChannel(msg.channel_id);
+ } else {
AsyncClient.updateLastViewedAt();
}
} else if (UserStore.getCurrentId() !== msg.user_id || post.type !== Constants.POST_TYPE_JOIN_LEAVE) {