appview-less bluesky client
27
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix pfp on account switcher not loading on load

dawn ff4752b3 e25c476a

+15 -17
+1 -6
src/components/AccountSwitcher.svelte
··· 3 3 import { AtpClient, resolveHandle } from '$lib/at/client.svelte'; 4 4 import type { Handle } from '@atcute/lexicons'; 5 5 import ProfilePicture from './ProfilePicture.svelte'; 6 - import PfpPlaceholder from './PfpPlaceholder.svelte'; 7 6 import Popup from './Popup.svelte'; 8 7 import Dropdown from './Dropdown.svelte'; 9 8 import AccountSelector from './AccountSelector.svelte'; ··· 113 112 onclick={toggleDropdown} 114 113 class="flex h-13 w-13 items-center justify-center rounded-sm shadow-md transition-all hover:scale-110 hover:shadow-xl hover:saturate-150" 115 114 > 116 - {#if selectedDid} 117 - <ProfilePicture {client} did={selectedDid} size={13} /> 118 - {:else} 119 - <PfpPlaceholder color="var(--nucleus-accent)" size={13} /> 120 - {/if} 115 + <ProfilePicture {client} did={selectedDid} size={13} /> 121 116 </button> 122 117 {/snippet} 123 118
+10 -10
src/components/ProfilePicture.svelte
··· 9 9 10 10 interface Props { 11 11 client: AtpClient; 12 - did: Did; 13 12 size: number; 13 + did: Did | null; 14 14 } 15 15 16 16 let { client, did, size }: Props = $props(); 17 17 18 - const avatarBlob = $derived(profiles.get(did)?.avatar); 19 - const avatarUrl: string | null = $derived( 20 - isBlob(avatarBlob) ? img('avatar_thumbnail', did, avatarBlob.ref.$link) : null 18 + const avatarBlob = $derived(did ? profiles.get(did)?.avatar : null); 19 + const avatarUrl = $derived( 20 + did && isBlob(avatarBlob) ? img('avatar_thumbnail', did, avatarBlob.ref.$link) : null 21 21 ); 22 22 23 - const loadProfile = async (targetDid: Did) => { 23 + const loadProfile = async (client: AtpClient, did: Did) => { 24 24 if (avatarBlob) return; 25 25 26 - const profile = await client.getProfile(targetDid); 26 + const profile = await client.getProfile(did); 27 27 if (profile.ok) profiles.set(did, profile.value); 28 - else console.error(`${targetDid}: failed to load pfp: ${profile.error}`); 28 + else console.error(`${did}: failed to load pfp: ${profile.error}`); 29 29 }; 30 30 31 31 $effect(() => { 32 - if (!client.user) return; 33 - loadProfile(did); 32 + if (!did) return; 33 + loadProfile(client, did); 34 34 }); 35 35 36 - const color = $derived(generateColorForDid(did)); 36 + const color = $derived(did ? generateColorForDid(did) : 'var(--nucleus-accent)'); 37 37 </script> 38 38 39 39 {#if avatarUrl}
+4 -1
src/lib/state.svelte.ts
··· 392 392 393 393 const threeDaysAgo = (Date.now() - 3 * 24 * 60 * 60 * 1000) * 1000; 394 394 395 - // fetch only 1 item to prompt the cursor 396 395 const res = await client.listRecordsUntil(subject, 'app.bsky.feed.post', undefined, threeDaysAgo); 397 396 if (!res.ok) return; 398 397 const postsWithUri = res.value.records.map( ··· 965 964 966 965 export const initialDone = new SvelteSet<Did>(); 967 966 export const fetchInitial = async (account: Account) => { 967 + const start = Date.now(); 968 968 const client = clients.get(account.did)!; 969 + const profile = await client.getProfile(); 970 + if (profile.ok) profiles.set(account.did, profile.value); 969 971 await Promise.allSettled([ 970 972 fetchBlocks(account), 971 973 fetchForInteractions(client, account.did), ··· 974 976 ) 975 977 ]); 976 978 initialDone.add(account.did); 979 + console.log(`initial done for ${account.did} in ${Date.now() - start}ms`); 977 980 }; 978 981 979 982 export const handleJetstreamEvent = async (event: JetstreamEvent) => {