From af75e717f463541e1552a84f815bcb5cabbb0f27 Mon Sep 17 00:00:00 2001 From: 0xsysr3ll <0xsysr3ll@pm.me> Date: Mon, 8 Dec 2025 21:38:20 +0100 Subject: [PATCH] refactor(webpush): remove redundant try-catch Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me> --- src/utils/pushSubscriptionHelpers.ts | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/utils/pushSubscriptionHelpers.ts b/src/utils/pushSubscriptionHelpers.ts index daed3dabb..e8b66e049 100644 --- a/src/utils/pushSubscriptionHelpers.ts +++ b/src/utils/pushSubscriptionHelpers.ts @@ -55,18 +55,12 @@ export const verifyPushSubscription = async ( const endpoint = subscription.endpoint; - try { - const { data } = await axios.get( - `/api/v1/user/${userId}/pushSubscription/${encodeURIComponent( - endpoint - )}` - ); + const { data } = await axios.get( + `/api/v1/user/${userId}/pushSubscription/${encodeURIComponent(endpoint)}` + ); - return data.endpoint === endpoint; - } catch { - return false; - } - } catch (error) { + return data.endpoint === endpoint; + } catch { return false; } }; @@ -85,18 +79,6 @@ export const verifyAndResubscribePushSubscription = async ( return true; } - try { - const { data: backendSubscriptions } = await axios.get< - UserPushSubscription[] - >(`/api/v1/user/${userId}/pushSubscriptions`); - - if (backendSubscriptions.length > 0) { - return true; - } - } catch { - // Continue with resubscribe logic - } - if (currentSettings.enablePushRegistration) { try { // Unsubscribe from the backend to clear the existing push subscription (keys and endpoint)