From 45fd6cd1bcf15c45c197256d9f484edc55e46d96 Mon Sep 17 00:00:00 2001 From: Iuri Pereira <689440+iuricmp@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:52:41 +0000 Subject: [PATCH] feat: universal login --- mobile/app/home/profile.tsx | 1 + mobile/redux/features/accountSlice.ts | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mobile/app/home/profile.tsx b/mobile/app/home/profile.tsx index 4fdcd84..30e5dd9 100644 --- a/mobile/app/home/profile.tsx +++ b/mobile/app/home/profile.tsx @@ -87,6 +87,7 @@ export default function Page() { }; const onPressLogout = async () => { + dispatch(clearLinking()); dispatch(logedOut()); }; diff --git a/mobile/redux/features/accountSlice.ts b/mobile/redux/features/accountSlice.ts index 1531c1e..68f5cb5 100644 --- a/mobile/redux/features/accountSlice.ts +++ b/mobile/redux/features/accountSlice.ts @@ -33,11 +33,17 @@ export const loggedIn = createAsyncThunk("account/ }); async function getAccountName(bech32: string, gnonative: GnoNativeApi) { - const accountNameStr = await gnonative.qEval("gno.land/r/demo/users", `GetUserByAddress("${bech32}").Name`); - console.log("GetUserByAddress result:", accountNameStr); - const accountName = accountNameStr.match(/\("(\w+)"/)?.[1]; - console.log("GetUserByAddress after regex", accountName); - return accountName + try { + console.log("GetUserByAddress request:", bech32); + const accountNameStr = await gnonative.qEval("gno.land/r/demo/users", `GetUserByAddress("${bech32}").Name`); + console.log("GetUserByAddress result:", accountNameStr); + const accountName = accountNameStr.match(/\("(\w+)"/)?.[1]; + console.log("GetUserByAddress after regex", accountName); + return accountName + } catch (error) { + console.error("Error getting account name", error); + } + return undefined; } interface AvatarCallTxParams {