This commit is contained in:
focp212@naver.com
2025-10-13 17:09:56 +09:00
parent 06518e02b9
commit 6d4f2c749e
2 changed files with 25 additions and 10 deletions

View File

@@ -16,6 +16,8 @@ export interface UserInfoState {
setSelectOptionsMids: (update: SetStateAction<Array<Record<string, string>>>) => void;
mid: string;
setMid: (update: SetStateAction<string>) => void;
firstAccess: boolean;
setFirstAccess: (update: SetStateAction<boolean>) => void;
};
const initialUserInfoState = {
@@ -23,7 +25,8 @@ const initialUserInfoState = {
userFavorite: [] as Array<UserFavorite>,
userMids: [] as Array<string>,
selectOptionsMids: [] as Array<Record<string, string>>,
mid: '' as string
mid: '' as string,
firstAccess: true as boolean,
} as UserInfoState;
export const createUserInfoStore = lens<UserInfoState>((set, get) => ({
@@ -85,7 +88,6 @@ export const createUserInfoStore = lens<UserInfoState>((set, get) => ({
return {
...state,
selectOptionsMids: [
...state.selectOptionsMids,
...newSelectOptionsMids
],
};
@@ -94,11 +96,21 @@ export const createUserInfoStore = lens<UserInfoState>((set, get) => ({
setMid: (update) => {
set((state: UserInfoState) => {
const newMid = (typeof update === 'function')
? update(state.mid): update;
? update(state.mid): update;
return {
...state,
mid: newMid
}
});
},
setFirstAccess: (update) => {
set((state: UserInfoState) => {
const newFirstAccess = (typeof update === 'function')
? update(state.firstAccess): update;
return {
...state,
firstAccess: newFirstAccess
}
});
}
}));