Skip to content

Commit

Permalink
cache oppfolging
Browse files Browse the repository at this point in the history
  • Loading branch information
johatr committed Oct 10, 2023
1 parent e31ada2 commit 6aebcb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/moduler/oppfolging-status/OppfolgingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from './oppfolging-selector';
import { hentOppfolging } from './oppfolging-slice';
import VidereSendBrukereEllerRenderChildren from './VidereSendBrukereEllerRenderChildren';
import { Status } from '../../createGenericSlice';

interface Props {
children: ReactNode;
Expand Down Expand Up @@ -48,8 +49,12 @@ const OppfolgingStatus = ({ children }: Props) => {
};

useEffect(() => {
dispatch(hentOppfolging());
dispatch(hentIdentitet());
if (avhengigheter[0] === Status.NOT_STARTED) {
dispatch(hentOppfolging());
}
if (avhengigheter[1] === Status.NOT_STARTED) {
dispatch(hentIdentitet());
}
}, []);

return (
Expand Down
8 changes: 4 additions & 4 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { configureStore } from '@reduxjs/toolkit';
import reducer from './reducer';
import { EnhancedStore } from '@reduxjs/toolkit/src/configureStore';

type Store = ReturnType<typeof createStore>;

let store: EnhancedStore | null = null;
const createStore = (preloadedState: any = undefined): EnhancedStore => {
const newStore: EnhancedStore = configureStore({
const createStore = (preloadedState: any = undefined) => {
const newStore = configureStore({
reducer: reducer,
preloadedState,
});
store = newStore;
return newStore;
};

type Store = ReturnType<typeof createStore>;

const key = 'aktivitetsplan-state';
export const getPreloadedStoreFromSessionStorage = (): Store | undefined => {
const serializedState = sessionStorage.getItem(key);
Expand Down

0 comments on commit 6aebcb5

Please sign in to comment.