[MM-60603] Don't follow threads when marking them as read on focus (#28263)

* [MM-60603] Don't follow threads when marking them as read on focus

* Fix tests

* Fix lint

* Fix the original bug in the API call
Этот коммит содержится в:
Devin Binnie
2024-09-26 09:02:11 -04:00
коммит произвёл GitHub
родитель 3428cd15b6
Коммит d58b048965
5 изменённых файлов: 44 добавлений и 71 удалений

Просмотреть файл

@@ -5,6 +5,7 @@ import {batchActions} from 'redux-batched-actions';
import {updateThreadRead} from 'mattermost-redux/actions/threads';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getThread} from 'mattermost-redux/selectors/entities/threads';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ThunkActionFunc} from 'mattermost-redux/types/actions';
@@ -56,8 +57,9 @@ export function markThreadAsRead(threadId: string): ThunkActionFunc<void, Global
const state = getState();
const currentUserId = getCurrentUserId(state);
const currentTeamId = getCurrentTeamId(state);
const thread = getThread(state, threadId);
if (isThreadOpen(state, threadId) && window.isActive && !isThreadManuallyUnread(state, threadId)) {
if (thread && isThreadOpen(state, threadId) && window.isActive && !isThreadManuallyUnread(state, threadId)) {
// mark thread as read on the server
dispatch(updateThreadRead(currentUserId, currentTeamId, threadId, Date.now()));
}