From 5bd2d9c2151524af9de77b111dc2d7c422af346d Mon Sep 17 00:00:00 2001 From: Valknar XXX Date: Tue, 28 Oct 2025 04:48:41 +0100 Subject: [PATCH] fix: handle undefined user name in UI components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added null check in getUserInitials function to return "??" for undefined names - Fixed logout button to handle undefined user.name when displaying first name - Prevents 500 errors when rendering components for users without names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/lib/components/logout-button/logout-button.svelte | 2 +- packages/frontend/src/lib/utils.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/lib/components/logout-button/logout-button.svelte b/packages/frontend/src/lib/components/logout-button/logout-button.svelte index f75da97..97ed1fb 100644 --- a/packages/frontend/src/lib/components/logout-button/logout-button.svelte +++ b/packages/frontend/src/lib/components/logout-button/logout-button.svelte @@ -130,7 +130,7 @@ $effect(() => {
- {user.name.split(" ")[0]} + {user.name ? user.name.split(" ")[0] : "User"} {slideProgress > 0.3 ? "Logout" : "Online"} diff --git a/packages/frontend/src/lib/utils.ts b/packages/frontend/src/lib/utils.ts index e8a0843..2ee5b29 100644 --- a/packages/frontend/src/lib/utils.ts +++ b/packages/frontend/src/lib/utils.ts @@ -27,6 +27,7 @@ export const calcReadingTime = (text: string) => { }; export const getUserInitials = (name: string) => { + if (!name) return "??"; return name .split(" ") .map((word) => word.charAt(0))