diff --git a/apps/web/src/components/App/App.tsx b/apps/web/src/components/App/App.tsx
index 603113a55..87a57ba53 100644
--- a/apps/web/src/components/App/App.tsx
+++ b/apps/web/src/components/App/App.tsx
@@ -9,10 +9,11 @@ import { WalletConnectProvider } from "../WalletConnect/WalletConnectProvider";
export const App = () => {
const { isSessionActive, isOnboarded } = useHandleSession();
- if (!isOnboarded()) {
+ if (!isSessionActive) {
+ if (isOnboarded()) {
+ return ;
+ }
return ;
- } else if (!isSessionActive) {
- return ;
} else {
return (
diff --git a/apps/web/src/views/SessionLogin/SessionLogin.tsx b/apps/web/src/views/SessionLogin/SessionLogin.tsx
index 15c0639ef..343a48ace 100644
--- a/apps/web/src/views/SessionLogin/SessionLogin.tsx
+++ b/apps/web/src/views/SessionLogin/SessionLogin.tsx
@@ -43,22 +43,14 @@ export const useLoginWithMnemonic = (
const mnemonic = (
JSON.parse(accounts.seedPhrases as unknown as string) as Record
)[defaultAccount.seedFingerPrint];
- await decrypt(mnemonic, data.password)
- .then(setupPersistence)
- .finally(() => {
- console.log("Decrypted mnemonic");
- window.location.reload();
- });
+ const result = await decrypt(mnemonic, data.password);
+ setupPersistence(result);
} else if (defaultAccount.type === "secret_key") {
const secretKey = (
JSON.parse(accounts.secretKeys as unknown as string) as Record
)[defaultAccount.address.pkh];
- await decrypt(secretKey, data.password)
- .then(setupPersistence)
- .finally(() => {
- console.log("Decrypted secret key");
- window.location.reload();
- });
+ const result = await decrypt(secretKey, data.password);
+ setupPersistence(result);
}
},
{ title: "Mnemonic or secret key not found" }
diff --git a/packages/state/src/hooks/session.ts b/packages/state/src/hooks/session.ts
index f228c0027..a98fd4756 100644
--- a/packages/state/src/hooks/session.ts
+++ b/packages/state/src/hooks/session.ts
@@ -1,19 +1,15 @@
-import { useAppDispatch } from "./useAppDispatch";
import { useAppSelector } from "./useAppSelector";
-import { setHasSession } from "../slices/session";
const SESSION_TIMEOUT = 30 * 60 * 1000; // 30 minutes from login
export const useHandleSession = () => {
const isOnboarded = () => !!localStorage.getItem("user_requirements_nonce");
- const isSessionActive = useAppSelector(state => state.session.hasSession);
- const dispatch = useAppDispatch();
+ const isSessionActive = useAppSelector(state => !!state.accounts.current);
const setupSessionTimeout = () => {
try {
const timeoutId = setTimeout(() => {
sessionStorage.clear();
- dispatch(setHasSession(false));
}, SESSION_TIMEOUT);
// Store timeout ID in case we need to clear it
diff --git a/packages/state/src/store.ts b/packages/state/src/store.ts
index 949e894e9..7317941dd 100644
--- a/packages/state/src/store.ts
+++ b/packages/state/src/store.ts
@@ -3,7 +3,6 @@ import { type Storage, persistReducer, persistStore } from "redux-persist";
import { makePersistConfigs, makeReducer } from "./reducer";
import { accountsSlice } from "./slices/accounts/accounts";
-import { setHasSession } from "./slices/session";
// Create initial store without persistence
export const makeStore = () => {
@@ -56,9 +55,9 @@ export const initializePersistence = (
// Update store's reducer
store.replaceReducer(finalReducer);
- store.dispatch(setHasSession(true));
const persistor = persistStore(store);
+
return { persistor };
};