diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 3287631d..6617c494 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -11,6 +11,7 @@ import { LemmyHttp, type GetSiteResponse, type MyUserInfo, + type Community, } from 'lemmy-js-client' import { get, writable } from 'svelte/store' import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js' @@ -43,7 +44,7 @@ export interface Profile { user?: PersonData username?: string avatar?: string - favorites?: ResumableItem[] + favorites?: Community[] color?: string } @@ -151,11 +152,10 @@ profile.subscribe(async (p) => { instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL) } if (!p) return - if (p.user) return instance.set(p.instance) // fetch the user because p.user is undefined - if (p?.jwt) { + if (p?.jwt && !p?.user) { const user = await userFromJwt(p.jwt, p.instance) .then((user) => { if (!user?.user) diff --git a/src/lib/components/ui/sidebar/CommunityList.svelte b/src/lib/components/ui/sidebar/CommunityList.svelte index c579a0fb..a8d243b8 100644 --- a/src/lib/components/ui/sidebar/CommunityList.svelte +++ b/src/lib/components/ui/sidebar/CommunityList.svelte @@ -1,52 +1,64 @@ {#each items.sort( (a, b) => a.title.localeCompare(b.title) ) as follow (follow.id)}
- + style="grid-column: 1; grid-row: 1;" + on:click={() => addFavorite(follow)} + > + + + {:else if isFavorites && $profile && hasFavorite($profile, follow.id)} + + {/if}
diff --git a/src/lib/components/ui/sidebar/Sidebar.svelte b/src/lib/components/ui/sidebar/Sidebar.svelte index bf722c84..1c3b05ea 100644 --- a/src/lib/components/ui/sidebar/Sidebar.svelte +++ b/src/lib/components/ui/sidebar/Sidebar.svelte @@ -28,6 +28,8 @@ import Application from '../../../../routes/admin/applications/Application.svelte' import { t } from '$lib/translations' import ItemList from '$lib/components/lemmy/generic/ItemList.svelte' + + $: if ($profile) console.log('profile changed')