Fix MarkThreadAsRead on notifications (#7417) (#7418)

(cherry picked from commit 0bfa4e429c)

Co-authored-by: Daniel Espino García <larkox@gmail.com>
This commit is contained in:
Mattermost Build 2023-06-21 11:29:16 +03:00 committed by GitHub
parent 8971b058c7
commit 53f8f312fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,8 +16,8 @@ import {requestNotifications} from 'react-native-permissions';
import {storeDeviceToken} from '@actions/app/global';
import {markChannelAsViewed} from '@actions/local/channel';
import {updateThread} from '@actions/local/thread';
import {backgroundNotification, openNotification} from '@actions/remote/notifications';
import {markThreadAsRead} from '@actions/remote/thread';
import {Device, Events, Navigation, PushNotification, Screens} from '@constants';
import DatabaseManager from '@database/manager';
import {DEFAULT_LOCALE, getLocalizedMessage, t} from '@i18n';
@ -90,7 +90,12 @@ class PushNotifications {
if (isCRTEnabled && payload.root_id) {
const thread = await getThreadById(database, payload.root_id);
if (thread?.isFollowing) {
markThreadAsRead(serverUrl, payload.team_id, payload.root_id);
const data: Partial<ThreadWithViewedAt> = {
unread_mentions: 0,
unread_replies: 0,
last_viewed_at: Date.now(),
};
updateThread(serverUrl, payload.root_id, data);
}
} else {
markChannelAsViewed(serverUrl, payload.channel_id);