From 17c6026729301336771d5aed1ac3d813d1e97157 Mon Sep 17 00:00:00 2001 From: Boris Trombert Date: Wed, 2 Oct 2024 09:39:48 +0200 Subject: [PATCH] redirect in general only if unauthorized actions in ws reconnect Changelog: fixed --- webapp/channels/src/actions/channel_actions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webapp/channels/src/actions/channel_actions.ts b/webapp/channels/src/actions/channel_actions.ts index dcb0de72b3..a581345260 100644 --- a/webapp/channels/src/actions/channel_actions.ts +++ b/webapp/channels/src/actions/channel_actions.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import type {ClientError} from '@infomaniak/mattermost-client'; import {batchActions} from 'redux-batched-actions'; import type {Channel} from '@mattermost/types/channels'; @@ -16,7 +17,7 @@ import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/commo import {getPost} from 'mattermost-redux/selectors/entities/posts'; import {getCurrentTeamUrl, getCurrentTeamId, getCurrentRelativeTeamUrl} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; -import type {ActionFuncAsync} from 'mattermost-redux/types/actions'; +import type {ActionFuncAsync, ActionResult} from 'mattermost-redux/types/actions'; import {trackEvent} from 'actions/telemetry_actions.jsx'; import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions'; @@ -102,9 +103,10 @@ export function loadDeletedPosts(channelId: string, lastDisconnectAt: number): A return async (dispatch, getState) => { const state = getState(); - const results = await dispatch(fetchDeletedPostsIds(channelId, lastDisconnectAt)); + const results = await dispatch(fetchDeletedPostsIds(channelId, lastDisconnectAt)) as ActionResult; + const error = results.error; - if ('error' in results) { + if (error && error.status_code === 403) { const currentTeamId = getCurrentTeamId(state); const redirectChannel = getRedirectChannelNameForTeam(state, currentTeamId); const teamUrl = getCurrentRelativeTeamUrl(state);