From 19ff61ca99cf7c279d231769d9fa94791ecd4fd6 Mon Sep 17 00:00:00 2001 From: Songkeys Date: Wed, 24 Aug 2022 14:43:57 +0800 Subject: [PATCH] fix: switching character --- components/common/Avatar/index.tsx | 4 +++- components/common/Character/index.tsx | 3 --- components/common/ConnectButton/index.tsx | 14 +++++++++----- utils/apis/indexer/character.ts | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/common/Avatar/index.tsx b/components/common/Avatar/index.tsx index cb455767..746c5cca 100644 --- a/components/common/Avatar/index.tsx +++ b/components/common/Avatar/index.tsx @@ -28,7 +28,7 @@ export default function Avatar({ const { isLoading, data: character } = useCharacter( characterId ?? initialCharacter?.characterId, { - enabled: Boolean(characterId) && !Boolean(initialCharacter) && !src, + enabled: Boolean(characterId) && !src, initialData: initialCharacter, } ); @@ -43,6 +43,8 @@ export default function Avatar({ src_ = ipfsLinkToHttpLink(src_); + // console.log({ isLoading, initialCharacter, character, src_ }); + return ( page.count > 0); @@ -288,9 +288,13 @@ function AccountList() { size="xs" className="my-2" checked={shouldNavigate} - onChange={(event) => - setShouldNavigate(event.currentTarget.checked) - } + onChange={(event) => { + if (event.currentTarget.checked) { + shouldNavigateHandles.open(); + } else { + shouldNavigateHandles.close(); + } + }} /> ), @@ -301,7 +305,7 @@ function AccountList() { if (shouldNavigate) { setTimeout(() => { router.push(composeCharacterHref(c.handle)); - }, 500); + }, 1000); } }, }); diff --git a/utils/apis/indexer/character.ts b/utils/apis/indexer/character.ts index 94a98177..1578c3ac 100644 --- a/utils/apis/indexer/character.ts +++ b/utils/apis/indexer/character.ts @@ -114,6 +114,7 @@ export function useCurrentCharacterId() { return useLocalStorage({ key: CurrentCharacterIdKey, serialize: (cid) => cid.toString(), + getInitialValueInEffect: false, }); } export function useDisconnectCurrentCharacter() {