diff --git a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx index 7229bfc2..8f0e18df 100644 --- a/frontend/src/components/HomeComponents/Tasks/Tasks.tsx +++ b/frontend/src/components/HomeComponents/Tasks/Tasks.tsx @@ -104,6 +104,7 @@ export const Tasks = ( due: '', tags: [] as string[], }); + const [isCreatingNewProject, setIsCreatingNewProject] = useState(false); const [isAddTaskOpen, setIsAddTaskOpen] = useState(false); const [_isDialogOpen, setIsDialogOpen] = useState(false); const [tagInput, setTagInput] = useState(''); @@ -286,6 +287,12 @@ export const Tasks = ( fetchTasksForEmail(); }, [props.email]); + useEffect(() => { + if (!isAddTaskOpen) { + setIsCreatingNewProject(false); + } + }, [isAddTaskOpen]); + syncTasksWithTwAndDb = useCallback(async () => { try { const { email: user_email, encryptionSecret, UUID } = props; @@ -308,8 +315,16 @@ export const Tasks = ( .where('email') .equals(user_email) .toArray(); - setTasks(sortTasksById(updatedTasks, 'desc')); - setTempTasks(sortTasksById(updatedTasks, 'desc')); + const sortedTasks = sortTasksById(updatedTasks, 'desc'); + setTasks(sortedTasks); + setTempTasks(sortedTasks); + + // Update unique projects after a successful sync so the Project dropdown is populated + const projectsSet = new Set(sortedTasks.map((task) => task.project)); + const filteredProjects = Array.from(projectsSet) + .filter((project) => project !== '') + .sort((a, b) => (a > b ? 1 : -1)); + setUniqueProjects(filteredProjects); }); // Store last sync timestamp using hashed key @@ -960,7 +975,7 @@ export const Tasks = ( your tasks -
+
} /> } /> } />
@@ -1075,25 +1090,76 @@ export const Tasks = (
-
-
+