feat: adds back resetApp

This commit is contained in:
Ben Kremer 2022-02-09 13:01:22 +01:00
parent d33bf9dcd1
commit 1ca7a5cfd1

View File

@ -156,8 +156,15 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
}
};
const subscribeToEvents = useCallback(
async (_client: Client) => {
const resetApp = () => {
setPairings([]);
setSession(undefined);
setBalances({});
setAccounts([]);
setChains([]);
};
const subscribeToEvents = useCallback(async (_client: Client) => {
if (typeof _client === "undefined") {
throw new Error("WalletConnect is not initialized");
}
@ -177,20 +184,15 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
});
_client.on(CLIENT_EVENTS.pairing.created, async (proposal: PairingTypes.Settled) => {
if (typeof client === "undefined") return;
setPairings(client.pairing.topics);
setPairings(_client.pairing.topics);
});
_client.on(CLIENT_EVENTS.session.deleted, (deletedSession: SessionTypes.Settled) => {
if (deletedSession.topic !== _session?.topic) return;
console.log("EVENT", "session_deleted");
// TODO:
// this.resetApp();
window.location.reload();
resetApp();
});
},
[client],
);
}, []);
const checkPersistedState = useCallback(
async (_client: Client) => {