From 6debf1b689f7d1b579436fd8a5db699f7f9865ee Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Thu, 16 Nov 2023 14:54:38 +0100 Subject: [PATCH 1/2] [TS migration] Migrate 'PushNotification.js' lib to TypeScript --- .../{PushNotification.js => PushNotification.ts} | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename src/libs/actions/{PushNotification.js => PushNotification.ts} (85%) diff --git a/src/libs/actions/PushNotification.js b/src/libs/actions/PushNotification.ts similarity index 85% rename from src/libs/actions/PushNotification.js rename to src/libs/actions/PushNotification.ts index 7abbd7b94ba0..1280b934989b 100644 --- a/src/libs/actions/PushNotification.js +++ b/src/libs/actions/PushNotification.ts @@ -6,15 +6,18 @@ import * as Device from './Device'; let isUserOptedInToPushNotifications = false; Onyx.connect({ key: ONYXKEYS.PUSH_NOTIFICATIONS_ENABLED, - callback: (val) => (isUserOptedInToPushNotifications = val), + callback: (val) => { + if (val === null) { + return; + } + isUserOptedInToPushNotifications = val; + }, }); /** * Record that user opted-in or opted-out of push notifications on the current device. - * - * @param {Boolean} isOptingIn */ -function setPushNotificationOptInStatus(isOptingIn) { +function setPushNotificationOptInStatus(isOptingIn: boolean) { Device.getDeviceID().then((deviceID) => { const commandName = isOptingIn ? 'OptInToPushNotifications' : 'OptOutOfPushNotifications'; const optimisticData = [ From 6316a022ea8d9849ad46d471bd18d8c7a6f62c4b Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Mon, 20 Nov 2023 16:26:22 +0100 Subject: [PATCH 2/2] Nit fix --- src/libs/actions/PushNotification.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/PushNotification.ts b/src/libs/actions/PushNotification.ts index 1280b934989b..888892fdc188 100644 --- a/src/libs/actions/PushNotification.ts +++ b/src/libs/actions/PushNotification.ts @@ -6,11 +6,11 @@ import * as Device from './Device'; let isUserOptedInToPushNotifications = false; Onyx.connect({ key: ONYXKEYS.PUSH_NOTIFICATIONS_ENABLED, - callback: (val) => { - if (val === null) { + callback: (value) => { + if (value === null) { return; } - isUserOptedInToPushNotifications = val; + isUserOptedInToPushNotifications = value; }, });