Retrigger data initialization

Retrigger data initialization process.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 06:33:40 +00:00
parent a14d1df2f0
commit bfac404786
3 changed files with 68 additions and 18 deletions

View File

@@ -1,4 +1,3 @@
import { BudgetData, Transaction } from './types';
import { DEFAULT_CATEGORY_BUDGETS, getInitialBudgetData } from './budgetUtils';
@@ -125,6 +124,10 @@ export const clearAllBudgetData = (): void => {
export const resetAllData = (): void => {
console.log('완전 초기화 시작 - resetAllData');
// dontShowWelcome 설정 값 백업
const dontShowWelcomeValue = localStorage.getItem('dontShowWelcome');
console.log('resetAllData - dontShowWelcome 백업 값:', dontShowWelcomeValue);
// 모든 관련 데이터 키 목록 (분석 페이지의 데이터 포함)
const dataKeys = [
'transactions',
@@ -144,7 +147,7 @@ export const resetAllData = (): void => {
'weeklyBudget', // 주간 예산
'monthlyBudget', // 월간 예산
'chartData', // 차트 데이터
'dontShowWelcome' // 환영 메시지 표시 여부
// 'dontShowWelcome' 키는 삭제 목록에서 제외
];
// 모든 관련 데이터 키 삭제
@@ -161,7 +164,7 @@ export const resetAllData = (): void => {
// 추가적으로 사용자 기기에 저장된 모든 데이터 검사 (역순으로 루프)
for (let i = localStorage.length - 1; i >= 0; i--) {
const key = localStorage.key(i);
if (key && (
if (key && key !== 'dontShowWelcome' && ( // dontShowWelcome 키는 제외
key.includes('expense') ||
key.includes('budget') ||
key.includes('transaction') ||
@@ -172,7 +175,6 @@ export const resetAllData = (): void => {
key.includes('month') ||
key.includes('sync') ||
key.includes('total') ||
key.includes('welcome') ||
key.includes('visited')
)) {
console.log(`추가 데이터 삭제: ${key}`);
@@ -190,5 +192,15 @@ export const resetAllData = (): void => {
}));
localStorage.setItem('categoryBudgets', JSON.stringify(DEFAULT_CATEGORY_BUDGETS));
// dontShowWelcome 값 복원 (백업한 값이 있는 경우)
if (dontShowWelcomeValue) {
console.log('resetAllData - dontShowWelcome 값 복원:', dontShowWelcomeValue);
localStorage.setItem('dontShowWelcome', dontShowWelcomeValue);
// 복원 확인
const restoredValue = localStorage.getItem('dontShowWelcome');
console.log('resetAllData - 복원 후 dontShowWelcome 값:', restoredValue);
}
console.log('모든 데이터가 초기화되었습니다.');
};