From 5c150a6aa307b75b392fbd77b99d6362d45a2e01 Mon Sep 17 00:00:00 2001 From: thislight Date: Sat, 17 Aug 2024 15:33:34 +0800 Subject: [PATCH] Home: fix the crash if no profile exists --- src/timelines/Home.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/timelines/Home.tsx b/src/timelines/Home.tsx index 5483771..2bd5e34 100644 --- a/src/timelines/Home.tsx +++ b/src/timelines/Home.tsx @@ -198,8 +198,16 @@ const Home: ParentComponent = (props) => { const settings$ = useStore($settings); const [profiles] = useSignedInProfiles(); - const profile = () => profiles()[0].inf; - const client = () => profiles()[0].client; + const profile = () => { + const all = profiles(); + if (all.length > 0) { + return all[0].inf; + } + }; + const client = () => { + const all = profiles() + return all?.[0]?.client + }; const navigate = useNavigate(); const [heroSrc, setHeroSrc] = createSignal({});