diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index dbc6cc991..2319f7133 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -33,6 +33,7 @@ import { getMyChannelMember, getRedirectChannelNameForTeam, getChannelsNameMapInTeam, + isManuallyUnread, } from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamId, getTeamByName} from 'mattermost-redux/selectors/entities/teams'; @@ -447,6 +448,17 @@ export function markChannelViewedAndRead(channelId, previousChannelId, markOnSer }; } +export function markChannelViewedAndReadOnReconnect(channelId) { + return (dispatch, getState) => { + if (isManuallyUnread(getState(), channelId)) { + return; + } + + dispatch(markChannelAsRead(channelId)); + dispatch(markChannelAsViewed(channelId)); + }; +} + export function toggleDMChannel(otherUserId, visible, channelId) { return async (dispatch, getState) => { const state = getState(); diff --git a/app/components/network_indicator/index.js b/app/components/network_indicator/index.js index 476146ac8..55c071d1e 100644 --- a/app/components/network_indicator/index.js +++ b/app/components/network_indicator/index.js @@ -9,7 +9,7 @@ import {init as initWebSocket, close as closeWebSocket} from 'mattermost-redux/a import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {connection} from 'app/actions/device'; -import {markChannelViewedAndRead, setChannelRetryFailed} from 'app/actions/views/channel'; +import {markChannelViewedAndReadOnReconnect, setChannelRetryFailed} from 'app/actions/views/channel'; import {setCurrentUserStatusOffline} from 'app/actions/views/user'; import {getConnection, isLandscape} from 'app/selectors/device'; @@ -35,7 +35,7 @@ function mapDispatchToProps(dispatch) { connection, initWebSocket, logout, - markChannelViewedAndRead, + markChannelViewedAndReadOnReconnect, setChannelRetryFailed, setCurrentUserStatusOffline, startPeriodicStatusUpdates, diff --git a/app/components/network_indicator/network_indicator.js b/app/components/network_indicator/network_indicator.js index fafe89440..deea0cc54 100644 --- a/app/components/network_indicator/network_indicator.js +++ b/app/components/network_indicator/network_indicator.js @@ -43,7 +43,7 @@ export default class NetworkIndicator extends PureComponent { closeWebSocket: PropTypes.func.isRequired, connection: PropTypes.func.isRequired, initWebSocket: PropTypes.func.isRequired, - markChannelViewedAndRead: PropTypes.func.isRequired, + markChannelViewedAndReadOnReconnect: PropTypes.func.isRequired, logout: PropTypes.func.isRequired, setChannelRetryFailed: PropTypes.func.isRequired, setCurrentUserStatusOffline: PropTypes.func.isRequired, @@ -245,7 +245,7 @@ export default class NetworkIndicator extends PureComponent { // foreground by tapping a notification from another channel this.clearNotificationTimeout = setTimeout(() => { PushNotifications.clearChannelNotifications(currentChannelId); - actions.markChannelViewedAndRead(currentChannelId); + actions.markChannelViewedAndReadOnReconnect(currentChannelId); }, 1000); } } else {