diff --git a/src/components/editor.tsx b/src/components/editor.tsx index 5300553..24e199c 100644 --- a/src/components/editor.tsx +++ b/src/components/editor.tsx @@ -342,9 +342,13 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . const file = readJson(editor.path) as TreeModel; editor.data = b3util.createTreeData(file.root); editor.autoId = b3util.refreshTreeDataId(editor.data); - editor.graph.changeData(editor.data); - editor.graph.layout(); - restoreViewport(); + editor.unsave = false; + updateState(); + if (editor.graph) { + editor.graph.changeData(editor.data); + editor.graph.layout(); + restoreViewport(); + } }; const checkSubtree = () => { diff --git a/src/components/workspace.tsx b/src/components/workspace.tsx index 486b955..c7f4ec2 100644 --- a/src/components/workspace.tsx +++ b/src/components/workspace.tsx @@ -28,10 +28,10 @@ export const Workspace: FC = () => { edit: useWorkspace((state) => state.edit), editing: useWorkspace((state) => state.editing), editors: useWorkspace((state) => state.editors), - modifiedEditors: useWorkspace((state) => state.modifiedEditors), fileTree: useWorkspace((state) => state.fileTree), find: useWorkspace((state) => state.find), init: useWorkspace((state) => state.init), + modifiedTime: useWorkspace((state) => state.modifiedTime), isShowingSearch: useWorkspace((state) => state.isShowingSearch), onShowingSearch: useWorkspace((state) => state.onShowingSearch), openProject: useWorkspace((state) => state.openProject), @@ -96,17 +96,11 @@ export const Workspace: FC = () => { useEffect(() => { const editor = workspace.editing; - if (editor && workspace.modifiedEditors.includes(editor)) { + if (editor?.alertReload) { if (isShowingAlert) { return; } setShowingAlert(true); - const modifiedEditors = workspace.modifiedEditors.filter((v) => v !== editor); - console.log( - "modified:", - editor.path, - modifiedEditors.map((v) => v.path) - ); const alert = modal.confirm({ centered: true, content: ( @@ -123,21 +117,21 @@ export const Workspace: FC = () => {