From 1ae847086e9388be1b082b427f9d74138e103fce Mon Sep 17 00:00:00 2001 From: 0xZensh Date: Sun, 15 Sep 2024 19:16:57 +0800 Subject: [PATCH] fix: fix index message page loading --- .../src/lib/components/messages/Index.svelte | 5 +++-- src/ic_panda_frontend/src/lib/stores/message.ts | 8 +------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/ic_panda_frontend/src/lib/components/messages/Index.svelte b/src/ic_panda_frontend/src/lib/components/messages/Index.svelte index 9323466..6fca4fa 100644 --- a/src/ic_panda_frontend/src/lib/components/messages/Index.svelte +++ b/src/ic_panda_frontend/src/lib/components/messages/Index.svelte @@ -23,10 +23,11 @@ async function initState() { myState = await myMessageStateAsync() myInfo = myState.info + myInfo_ = myInfo as Readable if ($myInfo) { const iv = await myState.myIV() const mk = await myState.masterKey(iv) - myInfo_ = myInfo as Readable + if (!mk || !mk.isOpened() || myState.masterKeyKind() !== mk.kind) { modalStore.trigger({ type: 'component', @@ -58,7 +59,7 @@ } -{#if myInfo_} +{#if $myInfo} {:else} diff --git a/src/ic_panda_frontend/src/lib/stores/message.ts b/src/ic_panda_frontend/src/lib/stores/message.ts index ddb5265..f498383 100644 --- a/src/ic_panda_frontend/src/lib/stores/message.ts +++ b/src/ic_panda_frontend/src/lib/stores/message.ts @@ -158,13 +158,7 @@ export class MyMessageState { this.info = derived(api.myInfoStore, ($info, set) => { if ($info) { this.setCacheUserInfo(Date.now(), $info) - set($info) - } else { - KVS.get<[number, UserInfo]>('Users', this.id).then((rt) => { - if (rt) { - set(rt[1]) - } - }) + this.refreshAllState(false).then(() => set($info)) } }) }