Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/libs/Notification/triggerNotifications.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/libs/actions/OnyxUpdates.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Comment on lines 54 to 58

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore notifications for HTTPS Onyx updates

On desktop web, notifications were previously triggered when applyHTTPSOnyxUpdates applied response.onyxData (the path used for API catch-up after reconnect/offline). Removing that call means report actions delivered via HTTPS no longer call showReportActionNotification, and notifications now only happen for Pusher updates in User.ts. The regression is visible when Pusher is disconnected or the user comes back online and the server returns missed report actions in onyxData: the UI updates, but no desktop notification fires.

Useful? React with 👍 / 👎.

Expand Down
19 changes: 18 additions & 1 deletion src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
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';
Expand All @@ -61,12 +60,13 @@
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';

let currentUserAccountID = -1;
let currentEmail = '';
Onyx.connect({

Check warning on line 69 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID;
Expand All @@ -75,7 +75,7 @@
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 78 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand Down Expand Up @@ -686,6 +686,23 @@
return isBefore(new Date(), new Date(blockedFromConciergeNVP.expiresAt));
}

function triggerNotifications(onyxUpdates: OnyxServerUpdate[]) {
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<ReportAction>) ?? {});

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.
Expand Down
Loading