Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-16477 Check for modified users on reconnect (#3028)
Browse files Browse the repository at this point in the history
* MM-16477 Move websocket status to redux

* MM-16477 Check for modified users on reconnect

* Update mattermost-redux

* Fix unit tests

* Update mattermost-redux

* Fix incorrect merge
  • Loading branch information
hmhealey committed Jul 8, 2019
1 parent e715fed commit 09bab23
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 93 deletions.
12 changes: 6 additions & 6 deletions actions/views/channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ describe('channel view actions', () => {
[channelId]: 12345,
},
},
websocket: {
lastDisconnectAt: 12344,
},
},
websocket: {
lastDisconnectAt: 12344,
},
});

Expand All @@ -448,9 +448,9 @@ describe('channel view actions', () => {
[channelId]: 12343,
},
},
websocket: {
lastDisconnectAt: 12344,
},
},
websocket: {
lastDisconnectAt: 12344,
},
});

Expand Down
21 changes: 16 additions & 5 deletions actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import {clearErrors, logError} from 'mattermost-redux/actions/errors';

import * as TeamActions from 'mattermost-redux/actions/teams';
import {getMe, getStatusesByIds, getProfilesByIds} from 'mattermost-redux/actions/users';
import {checkForModifiedUsers, getMe, getStatusesByIds, getProfilesByIds} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import {getCurrentUser, getCurrentUserId, getStatusForUserId, getUser} from 'mattermost-redux/selectors/entities/users';
import {getMyTeams, getCurrentRelativeTeamUrl, getCurrentTeamId, getCurrentTeamUrl} from 'mattermost-redux/selectors/entities/teams';
Expand Down Expand Up @@ -143,6 +143,7 @@ export function reconnect(includeWebSocket = true) {

dispatch({
type: GeneralTypes.WEBSOCKET_SUCCESS,
timestamp: Date.now(),
});

loadPluginsIfNecessary();
Expand All @@ -153,9 +154,9 @@ export function reconnect(includeWebSocket = true) {
}
});

const currentTeamId = getState().entities.teams.currentTeamId;
const state = getState();
const currentTeamId = state.entities.teams.currentTeamId;
if (currentTeamId) {
const state = getState();
const currentChannelId = getCurrentChannelId(state);
const mostRecentId = getMostRecentPostIdInChannel(state, currentChannelId);
const mostRecentPost = getPost(state, mostRecentId);
Expand All @@ -171,6 +172,10 @@ export function reconnect(includeWebSocket = true) {
dispatch(TeamActions.getMyTeamUnreads());
}

if (state.websocket.lastDisconnectAt) {
dispatch(checkForModifiedUsers());
}

dispatch(resetWsErrorCount());
dispatch(clearErrors());
}
Expand Down Expand Up @@ -217,7 +222,10 @@ export function unregisterAllPluginWebSocketEvents(pluginId) {

function handleFirstConnect() {
dispatch(batchActions([
{type: GeneralTypes.WEBSOCKET_SUCCESS},
{
type: GeneralTypes.WEBSOCKET_SUCCESS,
timestamp: Date.now(),
},
clearErrors(),
]));
}
Expand All @@ -227,7 +235,10 @@ function handleClose(failCount) {
dispatch(logError({type: 'critical', message: AnnouncementBarMessages.WEBSOCKET_PORT_ERROR}, true));
}
dispatch(batchActions([
{type: GeneralTypes.WEBSOCKET_FAILURE},
{
type: GeneralTypes.WEBSOCKET_FAILURE,
timestamp: Date.now(),
},
incrementWsErrorCount(),
]));
}
Expand Down
1 change: 1 addition & 0 deletions actions/websocket_actions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const mockState = {
selectedChannelId: 'otherChannel',
},
},
websocket: {},
};

jest.mock('stores/redux_store', () => {
Expand Down
2 changes: 0 additions & 2 deletions reducers/views/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import search from './search';
import notice from './notice';
import system from './system';
import channelSelectorModal from './channel_selector_modal';
import websocket from './websocket';

export default combineReducers({
admin,
Expand All @@ -32,5 +31,4 @@ export default combineReducers({
notice,
system,
channelSelectorModal,
websocket,
});
34 changes: 0 additions & 34 deletions reducers/views/websocket.js

This file was deleted.

45 changes: 0 additions & 45 deletions reducers/views/websocket.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion selectors/views/websocket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

export const getSocketStatus = (state) => state.views.websocket;
export const getSocketStatus = (state) => state.websocket;

0 comments on commit 09bab23

Please sign in to comment.