Skip to content

Commit

Permalink
chore(project): fix account session in dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Aug 4, 2021
1 parent decfa98 commit 931e318
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/stores/AccountStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ const setLoading = (loading: boolean) => {
});
};

let subscription: undefined | (() => void);
let refreshTimeout: number;

export const initializeAccount = async () => {
const { config } = ConfigStore.getRawState();

if (!config.cleengId) setLoading(false);

const storedSession: AuthData | null = persist.getItem(PERSIST_KEY_ACCOUNT) as AuthData | null;
let refreshTimeout: number;

AccountStore.subscribe(
// clear previous subscribe (for dev environment only)
if (subscription) {
subscription();
}

subscription = AccountStore.subscribe(
(state) => state.auth,
(authData) => {
window.clearTimeout(refreshTimeout);
Expand Down

0 comments on commit 931e318

Please sign in to comment.