diff --git a/src/components/TaskItem.tsx b/src/components/TaskItem.tsx index f234d3e..0240234 100644 --- a/src/components/TaskItem.tsx +++ b/src/components/TaskItem.tsx @@ -104,7 +104,10 @@ const TaskItem: React.FC = (props) => { {isTodayTask(task) ? (
setTaskScheduled(task, null)} + onClick={() => { + setTaskScheduled(task, null) + onChange(); + }} > = (props) => { ) : (
setTaskScheduled(task, new Date())} + onClick={() => { + setTaskScheduled(task, new Date()); + onChange(); + }} > = (props) => { const [tasks, setTasks] = useState([]); const visible = useRecoilValue(visibleState); const tasksLoadable = useRecoilValueLoadable(tasksState(query)); - const refresh = useRecoilRefresher_UNSTABLE(tasksState(query)); const themeStyle = useRecoilValue(themeStyleState); const { openInRightSidebar } = useRecoilValue(settingsState); const input = useRecoilValue(inputState); + const refreshAll = useRecoilCallback( + ({ snapshot, refresh }) => + () => { + for (const node of snapshot.getNodes_UNSTABLE()) { + refresh(node); + } + }, + [], + ); + useEffect(() => { switch (tasksLoadable.state) { case 'hasValue': { - const tasks = tasksLoadable.contents.filter((task: TaskEntityObject) => { - return task.content.toLowerCase().includes(input.toLowerCase()); - }); + const tasks = tasksLoadable.contents.filter( + (task: TaskEntityObject) => { + return task.content.toLowerCase().includes(input.toLowerCase()); + }, + ); setTasks(tasks); break; } @@ -53,9 +64,9 @@ const TaskSection: React.FC = (props) => { useEffect(() => { if (visible) { - refresh(); + refreshAll(); } - }, [visible, refresh]); + }, [visible, refreshAll]); const taskGroups = useMemo(() => { switch (props.groupBy) { @@ -92,7 +103,7 @@ const TaskSection: React.FC = (props) => { )} {(tasks ?? []).map((task) => ( - + ))}
);