From 5f269040fd75dd2274ef903b52aa31195dff6d5c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 01:28:18 +0000 Subject: [PATCH] Revert sync behavior after data reset The sync setting should be disabled after data reset. --- src/components/security/DataResetDialog.tsx | 4 ++-- src/components/sync/SyncExplanation.tsx | 2 +- src/utils/storageUtils.ts | 14 ++++---------- src/utils/sync/clearCloudData.ts | 5 ++--- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/components/security/DataResetDialog.tsx b/src/components/security/DataResetDialog.tsx index 644089b..b5d1d07 100644 --- a/src/components/security/DataResetDialog.tsx +++ b/src/components/security/DataResetDialog.tsx @@ -43,8 +43,8 @@ const DataResetDialog: React.FC = ({ 클라우드 데이터도 함께 삭제됩니다. {syncEnabled && ( -
- 동기화 설정은 계속 활성화 상태로 유지됩니다. +
+ 동기화 설정이 비활성화됩니다.
)} diff --git a/src/components/sync/SyncExplanation.tsx b/src/components/sync/SyncExplanation.tsx index c2b0722..cfaf665 100644 --- a/src/components/sync/SyncExplanation.tsx +++ b/src/components/sync/SyncExplanation.tsx @@ -16,7 +16,7 @@ const SyncExplanation: React.FC = ({ enabled }) => { 동기화 작동 방식 이 기능은 양방향 동기화입니다. 로그인 후 동기화를 켜면 서버 데이터와 로컬 데이터가 병합됩니다. - 데이터 초기화 후에도 동기화 버튼을 누르면 서버에 저장된 데이터를 다시 불러옵니다. + 데이터 초기화 시 동기화 설정은 자동으로 비활성화됩니다. ); diff --git a/src/utils/storageUtils.ts b/src/utils/storageUtils.ts index b236316..0ec7fc8 100644 --- a/src/utils/storageUtils.ts +++ b/src/utils/storageUtils.ts @@ -1,4 +1,3 @@ - import { Transaction } from '@/components/TransactionCard'; // 트랜잭션 데이터 불러오기 @@ -77,8 +76,6 @@ export const resetAllStorageData = (): void => { const authSession = localStorage.getItem('authSession'); const sbAuth = localStorage.getItem('sb-auth-token'); const supabase = localStorage.getItem('supabase.auth.token'); - // 동기화 설정 백업 (변경된 부분) - const syncEnabled = localStorage.getItem('syncEnabled'); // 모든 Storage 키 목록 (로그인 관련 항목 제외) const keysToRemove = [ @@ -102,7 +99,7 @@ export const resetAllStorageData = (): void => { 'budgetHistory', 'transactionHistory', 'lastSync', - // 'syncEnabled' 제거됨 - 동기화 설정은 보존 + 'syncEnabled', // 동기화 설정도 초기화 (변경된 부분) ]; // 키 삭제 @@ -156,11 +153,8 @@ export const resetAllStorageData = (): void => { localStorage.setItem('supabase.auth.token', supabase); } - // 동기화 설정 복원 (변경된 부분) - if (syncEnabled) { - localStorage.setItem('syncEnabled', syncEnabled); - console.log('동기화 설정 복원:', syncEnabled); - } + // 동기화 설정은 OFF로 설정 (변경된 부분) + localStorage.setItem('syncEnabled', 'false'); // 이벤트 발생 window.dispatchEvent(new Event('transactionUpdated')); @@ -168,7 +162,7 @@ export const resetAllStorageData = (): void => { window.dispatchEvent(new Event('categoryBudgetsUpdated')); window.dispatchEvent(new StorageEvent('storage')); - console.log('모든 저장소 데이터가 완전히 초기화되었습니다. (로그인 상태와 동기화 설정 유지)'); + console.log('모든 저장소 데이터가 완전히 초기화되었습니다. (동기화 설정이 OFF로 변경됨)'); } catch (error) { console.error('데이터 초기화 중 오류:', error); } diff --git a/src/utils/sync/clearCloudData.ts b/src/utils/sync/clearCloudData.ts index 92ed4ef..899b38c 100644 --- a/src/utils/sync/clearCloudData.ts +++ b/src/utils/sync/clearCloudData.ts @@ -54,11 +54,10 @@ export const clearCloudData = async (userId: string): Promise => { } // 동기화 설정 초기화 및 마지막 동기화 시간 초기화 - // 변경: 동기화 설정을 비활성화하지 않고 마지막 동기화 시간만 초기화 localStorage.removeItem('lastSync'); - // localStorage.setItem('syncEnabled', 'false'); 이 줄 제거 + localStorage.setItem('syncEnabled', 'false'); // 동기화 설정을 OFF로 변경 (수정된 부분) - console.log('클라우드 데이터 초기화 완료'); + console.log('클라우드 데이터 초기화 완료 및 동기화 설정 OFF'); return true; } catch (error) { console.error('클라우드 데이터 초기화 중 오류 발생:', error);