Skip to content

Commit

Permalink
Fix MarkThreadAsRead on notifications (#7417) (#7418)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0bfa4e4)

Co-authored-by: Daniel Espino García <[email protected]>
  • Loading branch information
mattermost-build and larkox authored Jun 21, 2023
1 parent 8971b05 commit 53f8f31
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/init/push_notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 53f8f31

Please sign in to comment.