Sync read channels across devices/apps (#1164)
This commit is contained in:
parent
7014c6035e
commit
a65811e088
9 changed files with 18 additions and 21 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import {markChannelAsRead, viewChannel} from 'mattermost-redux/actions/channels';
|
||||
import {markChannelAsRead, markChannelAsViewed} from 'mattermost-redux/actions/channels';
|
||||
import {ChannelTypes, TeamTypes} from 'mattermost-redux/action_types';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
|
@ -31,7 +31,7 @@ export function handleTeamChange(teamId, selectChannel = true) {
|
|||
const lastChannels = state.views.team.lastChannelForTeam[teamId] || [];
|
||||
const lastChannelId = lastChannels[0] || '';
|
||||
const currentChannelId = getCurrentChannelId(state);
|
||||
viewChannel(currentChannelId)(dispatch, getState);
|
||||
markChannelAsViewed(currentChannelId)(dispatch, getState);
|
||||
markChannelAsRead(lastChannelId, currentChannelId)(dispatch, getState);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default class ChannelDrawer extends Component {
|
|||
actions: PropTypes.shape({
|
||||
getTeams: PropTypes.func.isRequired,
|
||||
handleSelectChannel: PropTypes.func.isRequired,
|
||||
viewChannel: PropTypes.func.isRequired,
|
||||
markChannelAsViewed: PropTypes.func.isRequired,
|
||||
makeDirectChannel: PropTypes.func.isRequired,
|
||||
markChannelAsRead: PropTypes.func.isRequired,
|
||||
setChannelDisplayName: PropTypes.func.isRequired,
|
||||
|
|
@ -203,7 +203,7 @@ export default class ChannelDrawer extends Component {
|
|||
markChannelAsRead,
|
||||
setChannelLoading,
|
||||
setChannelDisplayName,
|
||||
viewChannel
|
||||
markChannelAsViewed
|
||||
} = actions;
|
||||
|
||||
setChannelLoading(channel.id !== currentChannelId);
|
||||
|
|
@ -217,7 +217,7 @@ export default class ChannelDrawer extends Component {
|
|||
// mark the channel as viewed after all the frame has flushed
|
||||
markChannelAsRead(channel.id, currentChannelId);
|
||||
if (channel.id !== currentChannelId) {
|
||||
viewChannel(currentChannelId);
|
||||
markChannelAsViewed(currentChannelId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {joinChannel, viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels';
|
||||
import {joinChannel, markChannelAsRead, markChannelAsViewed} from 'mattermost-redux/actions/channels';
|
||||
import {getTeams} from 'mattermost-redux/actions/teams';
|
||||
import {getCurrentTeamId, getMyTeamsCount} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ function mapDispatchToProps(dispatch) {
|
|||
getTeams,
|
||||
handleSelectChannel,
|
||||
joinChannel,
|
||||
viewChannel,
|
||||
markChannelAsViewed,
|
||||
makeDirectChannel,
|
||||
markChannelAsRead,
|
||||
setChannelDisplayName,
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ export default class Mattermost {
|
|||
}
|
||||
|
||||
if (data.type === 'clear') {
|
||||
markChannelAsRead(data.channel_id)(dispatch, getState);
|
||||
markChannelAsRead(data.channel_id, null, false)(dispatch, getState);
|
||||
} else if (foreground) {
|
||||
EventEmitter.emit(ViewTypes.NOTIFICATION_IN_APP, notification);
|
||||
} else if (userInteraction && !notification.localNotification) {
|
||||
|
|
|
|||
|
|
@ -37,14 +37,12 @@ class Channel extends PureComponent {
|
|||
connection: PropTypes.func.isRequired,
|
||||
loadChannelsIfNecessary: PropTypes.func.isRequired,
|
||||
loadProfilesAndTeamMembersForDMSidebar: PropTypes.func.isRequired,
|
||||
markChannelAsRead: PropTypes.func.isRequired,
|
||||
selectFirstAvailableTeam: PropTypes.func.isRequired,
|
||||
selectInitialChannel: PropTypes.func.isRequired,
|
||||
initWebSocket: PropTypes.func.isRequired,
|
||||
closeWebSocket: PropTypes.func.isRequired,
|
||||
startPeriodicStatusUpdates: PropTypes.func.isRequired,
|
||||
stopPeriodicStatusUpdates: PropTypes.func.isRequired,
|
||||
viewChannel: PropTypes.func.isRequired
|
||||
stopPeriodicStatusUpdates: PropTypes.func.isRequired
|
||||
}).isRequired,
|
||||
currentChannelId: PropTypes.string,
|
||||
channelsRequestFailed: PropTypes.bool,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels';
|
||||
import {startPeriodicStatusUpdates, stopPeriodicStatusUpdates} from 'mattermost-redux/actions/users';
|
||||
import {init as initWebSocket, close as closeWebSocket} from 'mattermost-redux/actions/websocket';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
|
@ -39,14 +38,12 @@ function mapDispatchToProps(dispatch) {
|
|||
connection,
|
||||
loadChannelsIfNecessary,
|
||||
loadProfilesAndTeamMembersForDMSidebar,
|
||||
markChannelAsRead,
|
||||
selectFirstAvailableTeam,
|
||||
selectInitialChannel,
|
||||
initWebSocket,
|
||||
closeWebSocket,
|
||||
startPeriodicStatusUpdates,
|
||||
stopPeriodicStatusUpdates,
|
||||
viewChannel
|
||||
stopPeriodicStatusUpdates
|
||||
}, dispatch)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels';
|
||||
import {markChannelAsRead, markChannelAsViewed} from 'mattermost-redux/actions/channels';
|
||||
import {selectPost} from 'mattermost-redux/actions/posts';
|
||||
import {clearSearch, removeSearchTerms, searchPosts} from 'mattermost-redux/actions/search';
|
||||
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
|
@ -43,12 +43,12 @@ function mapDispatchToProps(dispatch) {
|
|||
handleSelectChannel,
|
||||
loadThreadIfNecessary,
|
||||
markChannelAsRead,
|
||||
markChannelAsViewed,
|
||||
removeSearchTerms,
|
||||
searchPosts,
|
||||
selectPost,
|
||||
setChannelDisplayName,
|
||||
setChannelLoading,
|
||||
viewChannel
|
||||
setChannelLoading
|
||||
}, dispatch)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class Search extends PureComponent {
|
|||
clearSearch: PropTypes.func.isRequired,
|
||||
handleSearchDraftChanged: PropTypes.func.isRequired,
|
||||
loadThreadIfNecessary: PropTypes.func.isRequired,
|
||||
markChannelAsRead: PropTypes.func.isRequired,
|
||||
markChannelAsViewed: PropTypes.func.isRequired,
|
||||
removeSearchTerms: PropTypes.func.isRequired,
|
||||
searchPosts: PropTypes.func.isRequired,
|
||||
selectPost: PropTypes.func.isRequired
|
||||
|
|
@ -442,7 +444,7 @@ class Search extends PureComponent {
|
|||
markChannelAsRead,
|
||||
setChannelLoading,
|
||||
setChannelDisplayName,
|
||||
viewChannel
|
||||
markChannelAsViewed
|
||||
} = actions;
|
||||
|
||||
setChannelLoading(channelId !== currentChannelId);
|
||||
|
|
@ -454,7 +456,7 @@ class Search extends PureComponent {
|
|||
// mark the channel as viewed after all the frame has flushed
|
||||
markChannelAsRead(channelId, currentChannelId);
|
||||
if (channelId !== currentChannelId) {
|
||||
viewChannel(currentChannelId);
|
||||
markChannelAsViewed(currentChannelId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -3961,7 +3961,7 @@ makeerror@1.0.x:
|
|||
|
||||
mattermost-redux@mattermost/mattermost-redux#master:
|
||||
version "1.0.1"
|
||||
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/1c755c104fccbe30a2c31a423e031971d9a7c7d1"
|
||||
resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/cd2699d64fe044a9c9c32fcdd9c18ab7fa420e6d"
|
||||
dependencies:
|
||||
deep-equal "1.0.1"
|
||||
form-data "2.3.1"
|
||||
|
|
|
|||
Loading…
Reference in a new issue