refactor(webpush): remove redundant try-catch

Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me>
This commit is contained in:
0xsysr3ll
2025-12-08 21:38:20 +01:00
parent 306582e87f
commit af75e717f4

View File

@@ -55,18 +55,12 @@ export const verifyPushSubscription = async (
const endpoint = subscription.endpoint;
try {
const { data } = await axios.get<UserPushSubscription>(
`/api/v1/user/${userId}/pushSubscription/${encodeURIComponent(
endpoint
)}`
);
const { data } = await axios.get<UserPushSubscription>(
`/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)