Log out
diff --git a/frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx b/frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx
index ea803250..491a3b40 100644
--- a/frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx
+++ b/frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
import {
Sheet,
SheetContent,
@@ -45,6 +45,7 @@ import { useTaskAutoSync } from '@/components/utils/TaskAutoSync';
import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch';
import { Slider } from '@/components/ui/slider';
+import { hashKey } from '../Tasks/tasks-utils';
export const NavbarMobile = (
props: Props & { setIsOpen: (isOpen: boolean) => void; isOpen: boolean } & {
@@ -58,6 +59,8 @@ export const NavbarMobile = (
const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false);
const [autoSyncEnable, setAutoSyncEnable] = useState(false);
const [syncInterval, setSyncInterval] = useState(1);
+ const [autoSyncOnEdit, setAutoSyncOnEdit] = useState(true);
+
useTaskAutoSync({
isLoading: props.isLoading,
setIsLoading: props.setIsLoading,
@@ -65,6 +68,26 @@ export const NavbarMobile = (
syncInterval: syncInterval * 60000,
});
+ // Load setting from localStorage
+ useEffect(() => {
+ const hashedKey = hashKey('autoSyncOnEdit', props.email);
+ const stored = localStorage.getItem(hashedKey);
+ if (stored !== null) {
+ setAutoSyncOnEdit(stored === 'true');
+ } else {
+ localStorage.setItem(hashedKey, 'true');
+ setAutoSyncOnEdit(true);
+ }
+ }, [props.email]);
+
+ // Save setting and notify Tasks component
+ const handleAutoSyncOnEditChange = (checked: boolean) => {
+ setAutoSyncOnEdit(checked);
+ const hashedKey = hashKey('autoSyncOnEdit', props.email);
+ localStorage.setItem(hashedKey, checked.toString());
+ window.dispatchEvent(new Event('autoSyncOnEditChanged'));
+ };
+
const handleExportJSON = () => {
exportTasksAsJSON(props.tasks || []);
setIsExportDialogOpen(false);
@@ -215,6 +238,20 @@ export const NavbarMobile = (
/>
)}
+
+
+
+
+
diff --git a/frontend/src/components/HomeComponents/Navbar/__tests__/NavbarDesktop.test.tsx b/frontend/src/components/HomeComponents/Navbar/__tests__/NavbarDesktop.test.tsx
index 5f90174c..01852cac 100644
--- a/frontend/src/components/HomeComponents/Navbar/__tests__/NavbarDesktop.test.tsx
+++ b/frontend/src/components/HomeComponents/Navbar/__tests__/NavbarDesktop.test.tsx
@@ -154,7 +154,10 @@ describe('NavbarDesktop', () => {
render();
await userEvent.click(screen.getByText('CN'));
- await userEvent.click(screen.getByText('toggle'));
+
+ // Click the first toggle (Auto sync tasks)
+ const toggleButtons = screen.getAllByText('toggle');
+ await userEvent.click(toggleButtons[0]);
expect(screen.getByTestId('sync-slider')).toBeInTheDocument();
});
diff --git a/frontend/src/components/HomeComponents/Navbar/__tests__/__snapshots__/NavbarDesktop.test.tsx.snap b/frontend/src/components/HomeComponents/Navbar/__tests__/__snapshots__/NavbarDesktop.test.tsx.snap
index 4a8e3e30..5e87c5c0 100644
--- a/frontend/src/components/HomeComponents/Navbar/__tests__/__snapshots__/NavbarDesktop.test.tsx.snap
+++ b/frontend/src/components/HomeComponents/Navbar/__tests__/__snapshots__/NavbarDesktop.test.tsx.snap
@@ -374,6 +374,21 @@ exports[`NavbarDesktop renders consistently (snapshot) 1`] = `
+
+
+
+
+
+