From d5a721af7eed29d56f5e473dd49b742464cc1a5c Mon Sep 17 00:00:00 2001 From: Boris Trombert Date: Thu, 26 Sep 2024 10:57:52 +0200 Subject: [PATCH] prevent resetting lastDisconnectAt if it already exists to avoid user fetch bug on WS reconnect Changelog: fixed --- webapp/channels/src/actions/websocket_actions.jsx | 4 +++- .../packages/mattermost-redux/src/reducers/websocket.ts | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/webapp/channels/src/actions/websocket_actions.jsx b/webapp/channels/src/actions/websocket_actions.jsx index 87c3f46718..59677a8e8f 100644 --- a/webapp/channels/src/actions/websocket_actions.jsx +++ b/webapp/channels/src/actions/websocket_actions.jsx @@ -333,10 +333,12 @@ export async function reconnect(socketId) { }); if (state.websocket.lastDisconnectAt) { + console.log('lastConnectAt', state.websocket.lastConnectAt); + console.log('lastDisconnectAt', state.websocket.lastDisconnectAt); // eslint-disable-next-line no-console - console.log('[websocket_actions] lastDisconnectAt: ', state.websocket.lastDisconnectAt); dispatch(checkForModifiedUsers(true)); dispatch(TeamActions.getMyKSuites()); + console.log('[websocket_actions] lastDisconnectAt: ', state.websocket.lastDisconnectAt); } dispatch(resetWsErrorCount()); diff --git a/webapp/channels/src/packages/mattermost-redux/src/reducers/websocket.ts b/webapp/channels/src/packages/mattermost-redux/src/reducers/websocket.ts index 33786531bd..d0892e1ba8 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/reducers/websocket.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/reducers/websocket.ts @@ -25,15 +25,12 @@ export default function reducer(state = getInitialState(), action: AnyAction) { return { ...state, connected: false, - lastDisconnectAt: action.timestamp, + lastDisconnectAt: state.lastDisconnectAt || action.timestamp, }; } if (action.type === UserTypes.LOGOUT_SUCCESS) { - return getInitialState(); - } - - if (action.type === UserTypes.LOGOUT_SUCCESS) { + console.log('RESET WS STATE'); return getInitialState(); }