Skip to content

Commit

Permalink
fix state persistance bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntVal committed Apr 19, 2024
1 parent cf61aaa commit 6383cfa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
13 changes: 9 additions & 4 deletions apps/abstraxion-dashboard/components/AbstraxionWallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ export const AbstraxionWallets = () => {
useEffect(() => {
if (abstractAccount && previousData && data !== previousData) {
// Updating abstract account in context on poll
setAbstractAccount(
data?.smartAccounts?.nodes.find(
(smartAccount) => smartAccount.id === abstractAccount.id,
),
const node = data?.smartAccounts?.nodes.find(
(smartAccount) => smartAccount.id === abstractAccount.id,
);
setAbstractAccount({
...node,
userId: user?.user_id,
currentAuthenticatorIndex: node.authenticators.nodes.find(
(authenticator) => authenticator.authenticator === loginAuthenticator,
).authenticatorIndex,
});
}
}, [data, previousData]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import Image from "next/image";
import { WalletType, useAccount, useSuggestChainAndConnect } from "graz";
import { useQuery } from "@apollo/client";
import { useStytchUser } from "@stytch/nextjs";
import {
Button,
KeplrLogo,
Expand Down Expand Up @@ -49,6 +50,7 @@ export function AddAuthenticatorsForm({
const { loginAuthenticator } = useAbstraxionAccount();
const { client } = useAbstraxionSigningClient();
const { data: grazAccount } = useAccount();
const { user } = useStytchUser();
const { suggestAndConnect } = useSuggestChainAndConnect({
onSuccess: async () => await addKeplrAuthenticator(),
onError: () => setIsLoading(false),
Expand All @@ -72,11 +74,16 @@ export function AddAuthenticatorsForm({
stopPolling();
setIsLoading(false);
setIsSuccess(true);
setAbstractAccount(
data?.smartAccounts?.nodes.find(
(smartAccount) => smartAccount.id === abstractAccount.id,
),
const node = data?.smartAccounts?.nodes.find(
(smartAccount) => smartAccount.id === abstractAccount.id,
);
setAbstractAccount({
...node,
userId: user?.user_id,
currentAuthenticatorIndex: node.authenticators.nodes.find(
(authenticator) => authenticator.authenticator === loginAuthenticator,
).authenticatorIndex,
});
}
}, [data, previousData]);

Expand Down

0 comments on commit 6383cfa

Please sign in to comment.