Skip to content

Commit

Permalink
feat(session): add persist for user store
Browse files Browse the repository at this point in the history
  • Loading branch information
merely04 committed Feb 10, 2024
1 parent 8b67cb1 commit 62e23e8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/shared/session/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as typed from 'typed-contracts';
import {chainRoute, redirect, RouteInstance, RouteParams, RouteParamsAndQuery} from 'atomic-router';
import {attach, createEvent, createStore, Effect, sample} from 'effector';
import {persist} from 'effector-storage/local';
import {decodeToken} from 'react-jwt';

import {ApiV1UsersUserIdGet, apiV1UsersUserIdGet, apiV1UsersUserIdGetOk} from '~/shared/api';
Expand Down Expand Up @@ -39,6 +40,8 @@ export const sessionRequestFx = attach({
});

export const $user = createStore<typed.Get<typeof apiV1UsersUserIdGetOk> | null>(null);
persist({store: $user, key: 'user'});

const $authenticationStatus = createStore(AuthStatus.Initial);

$authenticationStatus.on(sessionRequestFx, (status) => {
Expand Down

0 comments on commit 62e23e8

Please sign in to comment.