diff options
author | Eric Bailey <git@esb.lol> | 2025-05-27 13:25:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-27 13:25:41 -0500 |
commit | 342f820ec01fac0ff914175575bc7afe64fa71fd (patch) | |
tree | 6000b1192701409a53195ee12178aa0305759d95 /src/lib/hooks | |
parent | df2f62e94ddee0b13ae48859617473f1905ec792 (diff) | |
download | voidsky-342f820ec01fac0ff914175575bc7afe64fa71fd.tar.zst |
Quiet some logs, fix a bug (#8404)
* Composer, 142k * Log geolocation error at most once per session * Clean thumb cache, 1.4m * Quiet generic network errors * Handle undefined notification payloads
Diffstat (limited to 'src/lib/hooks')
-rw-r--r-- | src/lib/hooks/useNotificationHandler.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index 9ddad7a16..f7cb6bae6 100644 --- a/src/lib/hooks/useNotificationHandler.ts +++ b/src/lib/hooks/useNotificationHandler.ts @@ -26,7 +26,13 @@ export type NotificationReason = | 'chat-message' | 'starterpack-joined' +/** + * Manually overridden type, but retains the possibility of + * `notification.request.trigger.payload` being `undefined`, as specified in + * the source types. + */ type NotificationPayload = + | undefined | { reason: Exclude<NotificationReason, 'chat-message'> uri: string @@ -47,7 +53,7 @@ const DEFAULT_HANDLER_OPTIONS = { } satisfies Notifications.NotificationBehavior // These need to stay outside the hook to persist between account switches -let storedPayload: NotificationPayload | undefined +let storedPayload: NotificationPayload let prevDate = 0 const logger = Logger.create(Logger.Context.Notifications) @@ -191,6 +197,11 @@ export function useNotificationsHandler() { logger.debug('Notifications: received', {e}) const payload = e.request.trigger.payload as NotificationPayload + + if (!payload) { + return DEFAULT_HANDLER_OPTIONS + } + if ( payload.reason === 'chat-message' && payload.recipientDid === currentAccount?.did @@ -231,6 +242,8 @@ export function useNotificationsHandler() { const payload = e.notification.request.trigger .payload as NotificationPayload + if (!payload) return + logger.debug( 'User pressed a notification, opening notifications tab', {}, |