diff --git a/src/components/AccountSwitcher.svelte b/src/components/AccountSwitcher.svelte
index 56d3d98..d161c65 100644
--- a/src/components/AccountSwitcher.svelte
+++ b/src/components/AccountSwitcher.svelte
@@ -3,7 +3,6 @@
import { AtpClient, resolveHandle } from '$lib/at/client.svelte';
import type { Handle } from '@atcute/lexicons';
import ProfilePicture from './ProfilePicture.svelte';
- import PfpPlaceholder from './PfpPlaceholder.svelte';
import Popup from './Popup.svelte';
import Dropdown from './Dropdown.svelte';
import AccountSelector from './AccountSelector.svelte';
@@ -113,11 +112,7 @@
onclick={toggleDropdown}
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"
>
- {#if selectedDid}
-
- {:else}
-
- {/if}
+
{/snippet}
diff --git a/src/components/ProfilePicture.svelte b/src/components/ProfilePicture.svelte
index 2ad4424..a461173 100644
--- a/src/components/ProfilePicture.svelte
+++ b/src/components/ProfilePicture.svelte
@@ -9,31 +9,31 @@
interface Props {
client: AtpClient;
- did: Did;
size: number;
+ did: Did | null;
}
let { client, did, size }: Props = $props();
- const avatarBlob = $derived(profiles.get(did)?.avatar);
- const avatarUrl: string | null = $derived(
- isBlob(avatarBlob) ? img('avatar_thumbnail', did, avatarBlob.ref.$link) : null
+ const avatarBlob = $derived(did ? profiles.get(did)?.avatar : null);
+ const avatarUrl = $derived(
+ did && isBlob(avatarBlob) ? img('avatar_thumbnail', did, avatarBlob.ref.$link) : null
);
- const loadProfile = async (targetDid: Did) => {
+ const loadProfile = async (client: AtpClient, did: Did) => {
if (avatarBlob) return;
- const profile = await client.getProfile(targetDid);
+ const profile = await client.getProfile(did);
if (profile.ok) profiles.set(did, profile.value);
- else console.error(`${targetDid}: failed to load pfp: ${profile.error}`);
+ else console.error(`${did}: failed to load pfp: ${profile.error}`);
};
$effect(() => {
- if (!client.user) return;
- loadProfile(did);
+ if (!did) return;
+ loadProfile(client, did);
});
- const color = $derived(generateColorForDid(did));
+ const color = $derived(did ? generateColorForDid(did) : 'var(--nucleus-accent)');
{#if avatarUrl}
diff --git a/src/lib/state.svelte.ts b/src/lib/state.svelte.ts
index 776e663..9b7d91e 100644
--- a/src/lib/state.svelte.ts
+++ b/src/lib/state.svelte.ts
@@ -392,7 +392,6 @@ export const fetchForInteractions = async (client: AtpClient, subject: Did) => {
const threeDaysAgo = (Date.now() - 3 * 24 * 60 * 60 * 1000) * 1000;
- // fetch only 1 item to prompt the cursor
const res = await client.listRecordsUntil(subject, 'app.bsky.feed.post', undefined, threeDaysAgo);
if (!res.ok) return;
const postsWithUri = res.value.records.map(
@@ -965,7 +964,10 @@ export const fetchInteractionsToFeedTimelineEnd = async (
export const initialDone = new SvelteSet();
export const fetchInitial = async (account: Account) => {
+ const start = Date.now();
const client = clients.get(account.did)!;
+ const profile = await client.getProfile();
+ if (profile.ok) profiles.set(account.did, profile.value);
await Promise.allSettled([
fetchBlocks(account),
fetchForInteractions(client, account.did),
@@ -974,6 +976,7 @@ export const fetchInitial = async (account: Account) => {
)
]);
initialDone.add(account.did);
+ console.log(`initial done for ${account.did} in ${Date.now() - start}ms`);
};
export const handleJetstreamEvent = async (event: JetstreamEvent) => {