Revert sync behavior after data reset
The sync setting should be disabled after data reset.
This commit is contained in:
@@ -43,8 +43,8 @@ const DataResetDialog: React.FC<DataResetDialogProps> = ({
|
||||
클라우드 데이터도 함께 삭제됩니다.
|
||||
</div>
|
||||
{syncEnabled && (
|
||||
<div className="mt-2 text-neuro-income">
|
||||
동기화 설정은 계속 활성화 상태로 유지됩니다.
|
||||
<div className="mt-2 text-amber-600">
|
||||
동기화 설정이 비활성화됩니다.
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -16,7 +16,7 @@ const SyncExplanation: React.FC<SyncExplanationProps> = ({ enabled }) => {
|
||||
<AlertTitle className="text-black">동기화 작동 방식</AlertTitle>
|
||||
<AlertDescription className="text-sm text-black">
|
||||
이 기능은 양방향 동기화입니다. 로그인 후 동기화를 켜면 서버 데이터와 로컬 데이터가 병합됩니다.
|
||||
데이터 초기화 후에도 동기화 버튼을 누르면 서버에 저장된 데이터를 다시 불러옵니다.
|
||||
데이터 초기화 시 동기화 설정은 자동으로 비활성화됩니다.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -54,11 +54,10 @@ export const clearCloudData = async (userId: string): Promise<boolean> => {
|
||||
}
|
||||
|
||||
// 동기화 설정 초기화 및 마지막 동기화 시간 초기화
|
||||
// 변경: 동기화 설정을 비활성화하지 않고 마지막 동기화 시간만 초기화
|
||||
localStorage.removeItem('lastSync');
|
||||
// localStorage.setItem('syncEnabled', 'false'); 이 줄 제거
|
||||
localStorage.setItem('syncEnabled', 'false'); // 동기화 설정을 OFF로 변경 (수정된 부분)
|
||||
|
||||
console.log('클라우드 데이터 초기화 완료');
|
||||
console.log('클라우드 데이터 초기화 완료 및 동기화 설정 OFF');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('클라우드 데이터 초기화 중 오류 발생:', error);
|
||||
|
||||
Reference in New Issue
Block a user