Home: fix the crash if no profile exists

This commit is contained in:
thislight 2024-08-17 15:33:34 +08:00
parent 64017b6b34
commit d9204b7dc0

View file

@ -198,8 +198,16 @@ const Home: ParentComponent = (props) => {
const settings$ = useStore($settings); const settings$ = useStore($settings);
const [profiles] = useSignedInProfiles(); const [profiles] = useSignedInProfiles();
const profile = () => profiles()[0].inf; const profile = () => {
const client = () => profiles()[0].client; const all = profiles();
if (all.length > 0) {
return all[0].inf;
}
};
const client = () => {
const all = profiles()
return all?.[0]?.client
};
const navigate = useNavigate(); const navigate = useNavigate();
const [heroSrc, setHeroSrc] = createSignal<HeroSource>({}); const [heroSrc, setHeroSrc] = createSignal<HeroSource>({});