Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed May 10, 2024
1 parent feae90f commit 5642411
Showing 1 changed file with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import applyOnyxUpdatesReliably from '@libs/actions/applyOnyxUpdatesReliably';
import * as ActiveClientManager from '@libs/ActiveClientManager';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import type {ReportActionPushNotificationData} from '@libs/Notification/PushNotification/NotificationType';
import getPolicyEmployeeAccountIDs from '@libs/PolicyEmployeeListUtils';
import {extractPolicyIDFromPath} from '@libs/PolicyUtils';
import {doesReportBelongToWorkspace, getReport} from '@libs/ReportUtils';
Expand All @@ -14,33 +15,6 @@ import ROUTES from '@src/ROUTES';
import type {OnyxUpdatesFromServer} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import PushNotification from '..';
import {ReportActionPushNotificationData} from '../NotificationType';

/**
* Manage push notification subscriptions on sign-in/sign-out.
*
* On Android, AuthScreens unmounts when the app is closed with the back button so we manage the
* push subscription when the session changes here.
*/
Onyx.connect({
key: ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID,
callback: (notificationID) => {
if (notificationID) {
PushNotification.register(notificationID);
PushNotification.init();

// Subscribe handlers for different push notification types
PushNotification.onReceived(PushNotification.TYPE.REPORT_COMMENT, applyOnyxData);
PushNotification.onSelected(PushNotification.TYPE.REPORT_COMMENT, navigateToReport);

PushNotification.onReceived(PushNotification.TYPE.MONEY_REQUEST, applyOnyxData);
PushNotification.onSelected(PushNotification.TYPE.MONEY_REQUEST, navigateToReport);
} else {
PushNotification.deregister();
PushNotification.clearNotifications();
}
},
});

let lastVisitedPath: string | undefined;
Onyx.connect({
Expand All @@ -53,6 +27,15 @@ Onyx.connect({
},
});

function getLastUpdateIDAppliedToClient(): Promise<number> {
return new Promise((resolve) => {
Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
callback: (value) => resolve(value ?? 0),
});
});
}

function applyOnyxData({reportID, reportActionID, onyxData, lastUpdateID, previousUpdateID}: ReportActionPushNotificationData): Promise<void> {
Log.info(`[PushNotification] Applying onyx data in the ${Visibility.isVisible() ? 'foreground' : 'background'}`, false, {reportID, reportActionID});

Expand Down Expand Up @@ -125,11 +108,28 @@ function navigateToReport({reportID, reportActionID}: ReportActionPushNotificati
return Promise.resolve();
}

function getLastUpdateIDAppliedToClient(): Promise<number> {
return new Promise((resolve) => {
Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
callback: (value) => resolve(value ?? 0),
});
});
}
/**
* Manage push notification subscriptions on sign-in/sign-out.
*
* On Android, AuthScreens unmounts when the app is closed with the back button so we manage the
* push subscription when the session changes here.
*/
Onyx.connect({
key: ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID,
callback: (notificationID) => {
if (notificationID) {
PushNotification.register(notificationID);
PushNotification.init();

// Subscribe handlers for different push notification types
PushNotification.onReceived(PushNotification.TYPE.REPORT_COMMENT, applyOnyxData);
PushNotification.onSelected(PushNotification.TYPE.REPORT_COMMENT, navigateToReport);

PushNotification.onReceived(PushNotification.TYPE.MONEY_REQUEST, applyOnyxData);
PushNotification.onSelected(PushNotification.TYPE.MONEY_REQUEST, navigateToReport);
} else {
PushNotification.deregister();
PushNotification.clearNotifications();
}
},
});

0 comments on commit 5642411

Please sign in to comment.