일정 관리 상태 복원 로직 수정 - back_forward 타입일 때만 복원
- 뒤로가기/앞으로가기: 상태 복원 - 새로고침(reload), 직접 진입(navigate): 상태 초기화
This commit is contained in:
parent
a3573ec990
commit
31f15fe20b
1 changed files with 9 additions and 10 deletions
|
|
@ -21,19 +21,18 @@ function AdminSchedule() {
|
|||
};
|
||||
|
||||
// sessionStorage에서 저장된 상태 복원
|
||||
// 일정 추가/수정 후 돌아올 때만 복원 (scheduleToast가 있을 때)
|
||||
// 새로고침이나 메뉴에서 직접 진입 시에는 초기화
|
||||
// 뒤로가기로 돌아올 때만 복원, 새로고침이나 직접 진입 시에는 초기화
|
||||
const getStoredState = () => {
|
||||
try {
|
||||
// scheduleToast가 있으면 일정 폼에서 돌아온 것 -> 상태 유지
|
||||
const hasScheduleToast = sessionStorage.getItem('scheduleToast');
|
||||
if (!hasScheduleToast) {
|
||||
// 일정 폼에서 돌아온 게 아니면 상태 초기화
|
||||
sessionStorage.removeItem('adminScheduleState');
|
||||
return null;
|
||||
}
|
||||
const navType = performance.getEntriesByType('navigation')[0]?.type;
|
||||
// 뒤로가기/앞으로가기일 때만 상태 복원
|
||||
if (navType === 'back_forward') {
|
||||
const stored = sessionStorage.getItem('adminScheduleState');
|
||||
return stored ? JSON.parse(stored) : null;
|
||||
}
|
||||
// 그 외(reload, navigate)는 상태 초기화
|
||||
sessionStorage.removeItem('adminScheduleState');
|
||||
return null;
|
||||
} catch { return null; }
|
||||
};
|
||||
const storedState = getStoredState();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue