Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request mattermost#2164 from mattermost/unread-tab-fix
Browse files Browse the repository at this point in the history
RC3 Fix badge and tab */(1) not disappearing until switching away from channel
  • Loading branch information
crspeller committed Feb 13, 2016
2 parents 902ee88 + c861a24 commit 4721e5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion web/react/components/channel_loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class ChannelLoader extends React.Component {

$(window).on('focus', function windowFocus() {
AsyncClient.updateLastViewedAt();
ChannelStore.resetCounts(ChannelStore.getCurrentId());
ChannelStore.emitChange();
window.isActive = true;
});

Expand Down Expand Up @@ -185,4 +187,4 @@ ChannelLoader.propTypes = {
intl: intlShape.isRequired
};

export default injectIntl(ChannelLoader);
export default injectIntl(ChannelLoader);
4 changes: 2 additions & 2 deletions web/react/stores/channel_store.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.storeChannels(action.channels);
ChannelStore.storeChannelMembers(action.members);
currentId = ChannelStore.getCurrentId();
if (currentId && !document.hidden) {
if (currentId && window.isActive) {
ChannelStore.resetCounts(currentId);
}
ChannelStore.setUnreadCounts();
Expand All @@ -321,7 +321,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.pStoreChannelMember(action.member);
}
currentId = ChannelStore.getCurrentId();
if (currentId && !document.hidden) {
if (currentId && window.isActive) {
ChannelStore.resetCounts(currentId);
}
ChannelStore.setUnreadCount(action.channel.id);
Expand Down
6 changes: 3 additions & 3 deletions web/react/stores/socket_store.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ function handleNewPostEvent(msg, translations) {

// Update channel state
if (ChannelStore.getCurrentId() === msg.channel_id) {
if (document.hidden) {
AsyncClient.getChannel(msg.channel_id);
} else {
if (window.isActive) {
AsyncClient.updateLastViewedAt();
} else {
AsyncClient.getChannel(msg.channel_id);
}
} else if (UserStore.getCurrentId() !== msg.user_id || post.type !== Constants.POST_TYPE_JOIN_LEAVE) {
AsyncClient.getChannel(msg.channel_id);
Expand Down

0 comments on commit 4721e5c

Please sign in to comment.