From 5f23b6a5c1bc7118655a261fa09283138c117764 Mon Sep 17 00:00:00 2001 From: marcin2121 <13873718+marcin2121@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:34:13 +0000 Subject: [PATCH] fix(profil): Improve error handling in push status check Extract error from Supabase query and handle it explicitly, as Supabase methods return errors instead of throwing them. Format the catch block for readability and log descriptive errors in Polish. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- app/profil/page.tsx | 12 +++++++++--- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/profil/page.tsx b/app/profil/page.tsx index f554ead..8e4acae 100644 --- a/app/profil/page.tsx +++ b/app/profil/page.tsx @@ -135,10 +135,16 @@ export default function ProfilePage() { const registration = await navigator.serviceWorker.ready; const sub = await registration.pushManager.getSubscription(); if (sub) { - const { data } = await supabase.from('push_subscriptions').select('topics').eq('endpoint', sub.endpoint).single(); - if (data?.topics) setSelectedTopics(data.topics); + const { data, error } = await supabase.from('push_subscriptions').select('topics').eq('endpoint', sub.endpoint).single(); + if (error) { + console.error('Błąd pobierania tematów powiadomień:', error); + } else if (data?.topics) { + setSelectedTopics(data.topics); + } } - } catch (e) { console.error(e); } + } catch (e) { + console.error('Błąd podczas sprawdzania statusu subskrypcji:', e); + } } else { setPushState('NOT_SUBSCRIBED'); } diff --git a/package-lock.json b/package-lock.json index 433dffd..368619f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,7 +77,7 @@ "shadcn": "^3.8.4", "tailwindcss": "^4", "tw-animate-css": "^1.4.0", - "typescript": "5.7.3" + "typescript": "^5.7.3" } }, "node_modules/@ai-sdk/gateway": { diff --git a/package.json b/package.json index 2ae4b5a..4dcb0d3 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,6 @@ "shadcn": "^3.8.4", "tailwindcss": "^4", "tw-animate-css": "^1.4.0", - "typescript": "5.7.3" + "typescript": "^5.7.3" } }