Fix data reset and deletion issues
- Ensure complete cloud data deletion during data reset. - Resolve app freeze issue when deleting transactions on the transaction history page.
This commit is contained in:
@@ -5,6 +5,7 @@ import { useToast } from '@/hooks/useToast.wrapper';
|
||||
import { resetAllStorageData } from '@/utils/storageUtils';
|
||||
import { clearCloudData } from '@/utils/syncUtils';
|
||||
import { useAuth } from '@/contexts/auth/AuthProvider';
|
||||
import { setSyncEnabled } from '@/utils/sync/syncSettings';
|
||||
|
||||
export interface DataResetResult {
|
||||
isCloudResetSuccess: boolean | null;
|
||||
@@ -31,6 +32,8 @@ export const useDataReset = () => {
|
||||
|
||||
if (cloudResetSuccess) {
|
||||
console.log('클라우드 데이터 초기화 성공');
|
||||
// 동기화 비활성화 (중요: 초기화 후 자동 동기화 방지)
|
||||
setSyncEnabled(false);
|
||||
} else {
|
||||
console.warn('클라우드 데이터 초기화 실패 또는 부분 성공');
|
||||
}
|
||||
@@ -82,6 +85,12 @@ export const useDataReset = () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 동기화 설정 초기화
|
||||
if (user) {
|
||||
localStorage.removeItem('lastSync');
|
||||
localStorage.setItem('syncEnabled', 'false');
|
||||
}
|
||||
|
||||
// 스토리지 이벤트 트리거하여 다른 컴포넌트에 변경 알림
|
||||
window.dispatchEvent(new Event('transactionUpdated'));
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
@@ -93,7 +102,7 @@ export const useDataReset = () => {
|
||||
if (cloudResetSuccess) {
|
||||
toast({
|
||||
title: "모든 데이터가 초기화되었습니다.",
|
||||
description: "로컬 및 클라우드의 모든 데이터가 초기화되었습니다.",
|
||||
description: "로컬 및 클라우드의 모든 데이터가 초기화되었습니다. 동기화 기능이 꺼졌습니다.",
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
|
||||
Reference in New Issue
Block a user