Ensure sync is disabled
The sync setting was not consistently being disabled in certain scenarios. This change ensures that the sync setting is properly disabled when expected.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { CloudUpload } from "lucide-react";
|
||||
import { useSyncSettings } from '@/hooks/useSyncSettings';
|
||||
import SyncStatus from '@/components/sync/SyncStatus';
|
||||
import SyncExplanation from '@/components/sync/SyncExplanation';
|
||||
import { isSyncEnabled } from '@/utils/sync/syncSettings';
|
||||
|
||||
const SyncSettings = () => {
|
||||
const {
|
||||
@@ -17,6 +18,30 @@ const SyncSettings = () => {
|
||||
handleManualSync
|
||||
} = useSyncSettings();
|
||||
|
||||
// 동기화 설정 변경 모니터링
|
||||
useEffect(() => {
|
||||
const checkSyncStatus = () => {
|
||||
const currentStatus = isSyncEnabled();
|
||||
console.log('현재 동기화 상태:', currentStatus ? '활성화됨' : '비활성화됨');
|
||||
};
|
||||
|
||||
// 초기 상태 확인
|
||||
checkSyncStatus();
|
||||
|
||||
// 스토리지 변경 이벤트에도 동기화 상태 확인 추가
|
||||
const handleStorageChange = () => {
|
||||
checkSyncStatus();
|
||||
};
|
||||
|
||||
window.addEventListener('storage', handleStorageChange);
|
||||
window.addEventListener('auth-state-changed', handleStorageChange);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('storage', handleStorageChange);
|
||||
window.removeEventListener('auth-state-changed', handleStorageChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* 동기화 토글 컨트롤 */}
|
||||
|
||||
@@ -16,6 +16,11 @@ const DataResetSection = () => {
|
||||
const handleResetAllData = async () => {
|
||||
await resetAllData();
|
||||
setIsResetDialogOpen(false);
|
||||
|
||||
// 초기화 후 페이지 새로고침
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -29,9 +34,7 @@ const DataResetSection = () => {
|
||||
<h3 className="font-medium">데이터 초기화</h3>
|
||||
<p className="text-xs text-gray-500 mt-1">
|
||||
{user
|
||||
? syncEnabled
|
||||
? "로컬 및 클라우드의 모든 예산, 지출 내역이 초기화됩니다. 동기화 설정은 유지됩니다."
|
||||
: "로컬 및 클라우드의 모든 예산, 지출 내역이 초기화됩니다."
|
||||
? "로컬 및 클라우드의 모든 예산, 지출 내역이 초기화됩니다. 동기화 설정은 비활성화됩니다."
|
||||
: "모든 예산, 지출 내역, 설정이 초기화됩니다."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user