added instant sync and fixed saving debounce

This commit is contained in:
2026-02-04 16:21:41 -06:00
parent e7b0967bb3
commit 54a0da9896
2 changed files with 131 additions and 22 deletions
+20 -2
View File
@@ -42,13 +42,22 @@ export const TaskDetail: Component<TaskDetailProps> = (props) => {
});
let debounceTimer: number | undefined;
let pendingContent: string | null = null;
const updateTaskContent = (html: string) => {
pendingContent = html;
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
updateTask(props.task.id, { content: html });
if (pendingContent !== null) {
updateTask(props.task.id, { content: pendingContent });
pendingContent = null;
}
}, 1000);
};
// Removed onCleanup to avoid lockup
const updateTitle = (val: string) => {
setTitle(val);
updateTask(props.task.id, { title: val });
@@ -87,7 +96,16 @@ export const TaskDetail: Component<TaskDetailProps> = (props) => {
const currentUrgency = () => calculateUrgencyFromDate(props.task.dueDate).toString();
return (
<Sheet open={props.isOpen} onOpenChange={(open) => !open && props.onClose()}>
<Sheet open={props.isOpen} onOpenChange={(open) => {
if (!open) {
// Flash save before closing to avoid lockup
if (pendingContent !== null) {
updateTask(props.task.id, { content: pendingContent });
pendingContent = null;
}
props.onClose();
}
}}>
<SheetContent
hideCloseButton
onOpenAutoFocus={(e) => {