From ef4fb9c8e0c6428733df0356ee4e48fedca20d2b Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 2 Mar 2023 16:52:54 +0200 Subject: [PATCH] fix entry for tablets (#7179) --- app/actions/remote/entry/common.ts | 10 +++------- app/actions/websocket/index.ts | 7 +++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/actions/remote/entry/common.ts b/app/actions/remote/entry/common.ts index 7919c790ef..312af8e341 100644 --- a/app/actions/remote/entry/common.ts +++ b/app/actions/remote/entry/common.ts @@ -1,8 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {markChannelAsViewed} from '@actions/local/channel'; -import {fetchMissingDirectChannelsInfo, fetchMyChannelsForTeam, handleKickFromChannel, markChannelAsRead, MyChannelsRequest} from '@actions/remote/channel'; +import {fetchMissingDirectChannelsInfo, fetchMyChannelsForTeam, handleKickFromChannel, MyChannelsRequest} from '@actions/remote/channel'; import {fetchGroupsForMember} from '@actions/remote/groups'; import {fetchPostsForUnreadChannels} from '@actions/remote/post'; import {MyPreferencesRequest, fetchMyPreferences} from '@actions/remote/preference'; @@ -440,9 +439,9 @@ export async function handleEntryAfterLoadNavigation( if (!currentTeamIdAfterLoad) { // First load or no team if (tabletDevice) { - await setCurrentTeamAndChannelId(operator, initialTeamId, ''); - } else { await setCurrentTeamAndChannelId(operator, initialTeamId, initialChannelId); + } else { + await setCurrentTeamAndChannelId(operator, initialTeamId, ''); } } else if (currentTeamIdAfterLoad !== currentTeamId) { // Switched teams while loading @@ -466,9 +465,6 @@ export async function handleEntryAfterLoadNavigation( } else { await setCurrentTeamAndChannelId(operator, initialTeamId, initialChannelId); } - } else if (tabletDevice && initialChannelId === currentChannelId) { - await markChannelAsRead(serverUrl, initialChannelId); - markChannelAsViewed(serverUrl, initialChannelId); } } catch (error) { logDebug('could not manage the entry after load navigation', error); diff --git a/app/actions/websocket/index.ts b/app/actions/websocket/index.ts index 917aa43dac..d8200e76e2 100644 --- a/app/actions/websocket/index.ts +++ b/app/actions/websocket/index.ts @@ -130,6 +130,13 @@ async function doReconnect(serverUrl: string) { if (models?.length) { await operator.batchRecords(models, 'doReconnect'); } + + const tabletDevice = await isTablet(); + if (tabletDevice && initialChannelId === currentChannelId) { + await markChannelAsRead(serverUrl, initialChannelId); + markChannelAsViewed(serverUrl, initialChannelId); + } + logInfo('WEBSOCKET RECONNECT MODELS BATCHING TOOK', `${Date.now() - dt}ms`); setTeamLoading(serverUrl, false);