260508_03_ENH: 새로고침 시 로그인 풀리는 문제 수정
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
|
|
||||||
const KEY = CryptoJS.enc.Utf8.parse("kr!-Kfp@-fr0nT-CrypT0-Key-STR");
|
const KEY = CryptoJS.enc.Utf8.parse("kr!-Kfp@-fr0nT-CrypT0-Key-STR");
|
||||||
const IV = CryptoJS.enc.Utf8.parse("kr!-Kfp@-IVST");
|
const IV = CryptoJS.enc.Utf8.parse("kr!-Kfp@Dash-IV");
|
||||||
|
|
||||||
export type WordArray = CryptoJS.lib.WordArray;
|
export type WordArray = CryptoJS.lib.WordArray;
|
||||||
|
|
||||||
|
|||||||
@@ -41,15 +41,6 @@ export const createLocalStorageAtom = <T>(
|
|||||||
// 하이드레이션(저장소 주입)과 사용자 set 경합 방지용 플래그
|
// 하이드레이션(저장소 주입)과 사용자 set 경합 방지용 플래그
|
||||||
let wasOverridden = false; // 마운트 이후 사용자가 값을 쓴 적이 있는지
|
let wasOverridden = false; // 마운트 이후 사용자가 값을 쓴 적이 있는지
|
||||||
|
|
||||||
baseAtom.onMount = (setAtom) => {
|
|
||||||
if (typeof window === "undefined" || wasOverridden) return;
|
|
||||||
|
|
||||||
const stored = getLocalStorage(key);
|
|
||||||
if (stored && typeof stored === "object") {
|
|
||||||
setAtom(stored as T);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const persistentAtom = atom(
|
const persistentAtom = atom(
|
||||||
(get) => get(baseAtom),
|
(get) => get(baseAtom),
|
||||||
(get, set, update: T | ((prev: T) => T)) => {
|
(get, set, update: T | ((prev: T) => T)) => {
|
||||||
@@ -89,15 +80,6 @@ export const createSessionStorageAtom = <T>(
|
|||||||
const realInitialValue = loadInitialState("session", key, initialValue);
|
const realInitialValue = loadInitialState("session", key, initialValue);
|
||||||
const baseAtom: PrimitiveAtom<T> = atom<T>(realInitialValue);
|
const baseAtom: PrimitiveAtom<T> = atom<T>(realInitialValue);
|
||||||
|
|
||||||
baseAtom.onMount = (setAtom) => {
|
|
||||||
if (typeof window === "undefined") return;
|
|
||||||
|
|
||||||
const stored = getSessionStorage(key);
|
|
||||||
if (stored && typeof stored === "object") {
|
|
||||||
setAtom(stored as T);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const persistentAtom = atom(
|
const persistentAtom = atom(
|
||||||
(get) => get(baseAtom),
|
(get) => get(baseAtom),
|
||||||
(get, set, update: T | ((prev: T) => T)) => {
|
(get, set, update: T | ((prev: T) => T)) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user