diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-07-11 00:36:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-10 16:36:53 -0500 |
commit | 377d80e21df668c50585b1131bf1b7f0528bacd0 (patch) | |
tree | 30af22f8a2034b351bdc8dedee291f588677cfd9 /src/lib/notifications/notifications.ts | |
parent | 22bda086d0f2e6e8656d7eb79dea7b551e587736 (diff) | |
download | voidsky-377d80e21df668c50585b1131bf1b7f0528bacd0.tar.zst |
Handle notifications on first load (#8629)
* add getInitialURL * get deep linking working * actually handle as push instead * push to route instead of setting initial path * pop to on top of notifications * fix comment * change chat-message handling * add metrics * don't reopen due to notif multiple times * extract data from notification differently on android * sorry sorry annoying naming nits, align logger --------- Co-authored-by: Eric Bailey <git@esb.lol>
Diffstat (limited to 'src/lib/notifications/notifications.ts')
-rw-r--r-- | src/lib/notifications/notifications.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index 2c0487ab7..94b3f6de3 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -6,13 +6,11 @@ import {type AtpAgent} from '@atproto/api' import debounce from 'lodash.debounce' import {PUBLIC_APPVIEW_DID, PUBLIC_STAGING_APPVIEW_DID} from '#/lib/constants' -import {Logger} from '#/logger' +import {logger as notyLogger} from '#/lib/notifications/util' import {isNative} from '#/platform/detection' import {type SessionAccount, useAgent, useSession} from '#/state/session' import BackgroundNotificationHandler from '#/../modules/expo-background-notification-handler' -const logger = Logger.create(Logger.Context.Notifications) - /** * @private * Registers the device's push notification token with the Bluesky server. @@ -36,12 +34,12 @@ async function _registerPushToken({ appId: 'xyz.blueskyweb.app', }) - logger.debug(`registerPushToken: success`, { + notyLogger.debug(`registerPushToken: success`, { tokenType: token.type, token: token.data, }) } catch (error) { - logger.error(`registerPushToken: failed`, {safeMessage: error}) + notyLogger.error(`registerPushToken: failed`, {safeMessage: error}) } } @@ -80,7 +78,7 @@ export function useRegisterPushToken() { */ async function getPushToken() { const granted = (await Notifications.getPermissionsAsync()).granted - logger.debug(`getPushToken`, {granted}) + notyLogger.debug(`getPushToken`, {granted}) if (granted) { return Notifications.getDevicePushTokenAsync() } @@ -115,7 +113,9 @@ export function useGetAndRegisterPushToken() { */ const token = await getPushToken() - logger.debug(`useGetAndRegisterPushToken`, {token: token ?? 'undefined'}) + notyLogger.debug(`useGetAndRegisterPushToken`, { + token: token ?? 'undefined', + }) if (token) { /** @@ -147,7 +147,7 @@ export function useNotificationsRegistration() { */ if (!currentAccount) return - logger.debug(`useNotificationsRegistration`) + notyLogger.debug(`useNotificationsRegistration`) /** * Init push token, if permissions are granted already. If they weren't, @@ -168,7 +168,7 @@ export function useNotificationsRegistration() { */ const subscription = Notifications.addPushTokenListener(async token => { registerPushToken({token}) - logger.debug(`addPushTokenListener callback`, {token}) + notyLogger.debug(`addPushTokenListener callback`, {token}) }) return () => { @@ -202,7 +202,7 @@ export function useRequestNotificationsPermission() { const res = await Notifications.requestPermissionsAsync() - logger.metric(`notifications:request`, { + notyLogger.metric(`notifications:request`, { context: context, status: res.status, }) |