diff --git a/src/libs/Notification/triggerNotifications.ts b/src/libs/Notification/triggerNotifications.ts deleted file mode 100644 index 30b6f50637bf..000000000000 --- a/src/libs/Notification/triggerNotifications.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type {OnyxCollection} from 'react-native-onyx'; -import {showReportActionNotification} from '@libs/actions/Report'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {ReportAction} from '@src/types/onyx'; -import type {OnyxServerUpdate} from '@src/types/onyx/OnyxUpdatesFromServer'; - -export default function triggerNotifications(onyxUpdates: OnyxServerUpdate[]): void { - for (const update of onyxUpdates) { - if (!update.shouldNotify && !update.shouldShowPushNotification) { - continue; - } - - const reportID = update.key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); - const reportActions = Object.values((update.value as OnyxCollection) ?? {}); - - for (const action of reportActions) { - if (action) { - showReportActionNotification(reportID, action); - } - } - } -} diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts index 3feb758a8f07..053a0b739140 100644 --- a/src/libs/actions/OnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdates.ts @@ -1,11 +1,8 @@ -import {Platform} from 'react-native'; import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {Merge} from 'type-fest'; import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; -import {isMobile} from '@libs/Browser'; import Log from '@libs/Log'; -import triggerNotifications from '@libs/Notification/triggerNotifications'; import Performance from '@libs/Performance'; import PusherUtils from '@libs/PusherUtils'; import CONST from '@src/CONST'; @@ -56,10 +53,6 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response, lastUpdateI return onyxDataUpdatePromise .then(() => { - // Trigger notifications only on successful responses. - if (Platform.OS === 'web' && !isMobile() && response.jsonCode === 200 && response.onyxData?.length) { - triggerNotifications(response.onyxData); - } // Handle the request's success/failure data (client-side data) if (response.jsonCode === 200 && request.successData) { return updateHandler(request.successData); diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 16a62c36ae1d..a0e14ff5cbc9 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -35,7 +35,6 @@ import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import {isOffline} from '@libs/Network/NetworkStore'; import * as SequentialQueue from '@libs/Network/SequentialQueue'; -import triggerNotifications from '@libs/Notification/triggerNotifications'; import * as NumberUtils from '@libs/NumberUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import Pusher from '@libs/Pusher'; @@ -61,6 +60,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {reconnectApp} from './App'; import applyOnyxUpdatesReliably from './applyOnyxUpdatesReliably'; import {openOldDotLink} from './Link'; +import {showReportActionNotification} from './Report'; import {resendValidateCode as sessionResendValidateCode} from './Session'; import Timing from './Timing'; @@ -686,6 +686,23 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry) ?? {}); + + for (const action of reportActions) { + if (action) { + showReportActionNotification(reportID, action); + } + } + } +} + const isChannelMuted = (reportId: string) => new Promise((resolve) => { // We use `connectWithoutView` here since this connection is non-reactive in nature.