feat: update user authentication cookies and implement service worker timeout for push subscription checks
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m34s
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m34s
This commit is contained in:
@@ -179,7 +179,12 @@ export function getPushPermissionState(): NotificationPermission | 'unsupported'
|
||||
export async function isSubscribedToPush(): Promise<boolean> {
|
||||
if (!('serviceWorker' in navigator) || !('PushManager' in window)) return false
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.ready
|
||||
const registration = await Promise.race([
|
||||
navigator.serviceWorker.ready,
|
||||
new Promise<never>((_, reject) =>
|
||||
setTimeout(() => reject(new Error('SW ready timeout')), 3_000),
|
||||
),
|
||||
])
|
||||
const subscription = await registration.pushManager.getSubscription()
|
||||
return subscription !== null
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user