diff --git a/src/lib/accounts/accountStore.ts b/src/lib/accounts/accountStore.ts index 0358d63..4b77533 100644 --- a/src/lib/accounts/accountStore.ts +++ b/src/lib/accounts/accountStore.ts @@ -3,13 +3,14 @@ import { type AccountKeyDB, openAccountKeyDB } from './accountKeyDB'; import { BlahIdentity, type BlahIdentityFile, type BlahProfile } from '@blah-im/core/identity'; import { type IdentityFileDB, openIdentityFileDB } from '$lib/identityFiles/identityFileDB'; import { BlahKeyPair } from '@blah-im/core/crypto'; +import { persisted } from 'svelte-persisted-store'; export type Account = BlahIdentityFile & { holdingKeyPrivate: boolean; holdingPrivateOfActKey?: string; }; -export class AccountStore implements Readable { +class AccountStore implements Readable { private keyDB: AccountKeyDB; private identityFileDB: IdentityFileDB; private internalStore = writable([]); @@ -83,3 +84,16 @@ export class AccountStore implements Readable { await this.saveIdentityFile(identity); } } + +let accountStore: AccountStore | undefined; + +export async function openAccountStore(): Promise { + if (!accountStore) { + accountStore = await AccountStore.open(); + } + return accountStore; +} + +export type { AccountStore }; + +export const currentAccountStore = persisted('weblah-current-account-id-key', null); diff --git a/src/lib/components/ProfilePicture.svelte b/src/lib/components/ProfilePicture.svelte new file mode 100644 index 0000000..1eb6436 --- /dev/null +++ b/src/lib/components/ProfilePicture.svelte @@ -0,0 +1,21 @@ + + +{#if account} + {#key account.id_key} + + {/key} + {account.profile.signee.payload.name} +{:else} +
+ Account Unavailable +{/if} diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index ee87f2c..395755a 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -2,6 +2,7 @@ import { page } from '$app/stores'; import { onNavigate } from '$app/navigation'; import ChatList from './ChatList.svelte'; + import SettingsList from './settings/SettingsList.svelte'; onNavigate((navigation) => { if (!document.startViewTransition) return; @@ -14,10 +15,9 @@ }); }); + $: isSettings = $page.route.id?.startsWith('/settings'); $: mainVisible = - !!$page.params.chatId || - ($page.route.id?.startsWith('/settings') && - !$page.route.id?.startsWith('/settings/_mobile_empty')); + !!$page.params.chatId || (isSettings && !$page.route.id?.startsWith('/settings/_mobile_empty'));
+ {#if isSettings} + + {/if} {#if mainVisible}
- + + + @@ -46,8 +54,8 @@