chore(react/type_widget): bring back update interval

This commit is contained in:
Elian Doran
2025-09-20 13:03:46 +03:00
parent b19da81572
commit 6dd939df14
4 changed files with 11 additions and 7 deletions

View File

@@ -75,11 +75,12 @@ export function useSpacedUpdate(callback: () => void | Promise<void>, interval =
return spacedUpdateRef.current;
}
export function useEditorSpacedUpdate({ note, getData, onContentChange, dataSaved }: {
export function useEditorSpacedUpdate({ note, getData, onContentChange, dataSaved, updateInterval }: {
note: FNote,
getData: () => Promise<object | undefined> | object | undefined,
onContentChange: (newContent: string) => void,
dataSaved?: () => void
dataSaved?: () => void,
updateInterval?: number;
}) {
const parentComponent = useContext(ParentComponent);
const blob = useNoteBlob(note, parentComponent?.componentId);
@@ -105,6 +106,9 @@ export function useEditorSpacedUpdate({ note, getData, onContentChange, dataSave
spacedUpdate.allowUpdateWithoutChange(() => onContentChange(blob.content));
}, [ blob ]);
// React to update interval changes.
useEffect(() => spacedUpdate.setUpdateInterval(updateInterval), [ updateInterval ]);
return spacedUpdate;
}