Fix MarkThreadAsRead on notifications (#7417)

This commit is contained in:
Daniel Espino García 2023-06-20 16:24:03 +02:00 committed by GitHub
parent 21a4f606b4
commit 0bfa4e429c
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);