detect file changes
This commit is contained in:
1 parent
298cedbbb3
commit
cf1c33891f
4 files changed
+33
-12
No files matched your search
@@ -152,7 +152,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
filterFocus: true,
|
||||
filterType: "content",
|
||||
placeholder: "",
|
||||
isFocused: false
|
||||
isFocused: false,
|
||||
});
|
||||
|
||||
const onSearchChange = (option: FilterOption) => {
|
||||
@@ -327,7 +327,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
}
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
const refresh = () => {
|
||||
const rootData = findDataById("1");
|
||||
const rootNode = b3util.createNode(rootData);
|
||||
editor.data = b3util.createTreeData(rootNode);
|
||||
@@ -337,11 +337,13 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
restoreViewport();
|
||||
};
|
||||
|
||||
const reload = () => {};
|
||||
|
||||
const checkSubtree = () => {
|
||||
if (editor.graph) {
|
||||
const data = findDataById("1");
|
||||
if (b3util.isSubtreeUpdated(data)) {
|
||||
reload();
|
||||
refresh();
|
||||
pushHistory();
|
||||
onChange();
|
||||
}
|
||||
@@ -383,7 +385,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
b3util.copyFromNode(data, newNode);
|
||||
data.size = b3util.calcTreeDataSize(data);
|
||||
if (oldNode.path !== newNode.path) {
|
||||
reload();
|
||||
refresh();
|
||||
selectNode(null);
|
||||
selectNode(data.id);
|
||||
} else {
|
||||
@@ -623,6 +625,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
export: editor.export,
|
||||
desc: editor.desc,
|
||||
} as TreeModel;
|
||||
editor.modifiedTime = Date.now();
|
||||
fs.writeFileSync(path, JSON.stringify(treeModel, null, 2));
|
||||
workspace.updateFileMeta(editor);
|
||||
editor.unsave = false;
|
||||
@@ -684,7 +687,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
} as TreeModel;
|
||||
fs.writeFileSync(subpath, JSON.stringify(subtreeModel, null, 2));
|
||||
data.path = workspace.relative(subpath);
|
||||
reload();
|
||||
refresh();
|
||||
pushHistory();
|
||||
onChange();
|
||||
}, 200);
|
||||
@@ -1006,6 +1009,10 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
redo();
|
||||
break;
|
||||
}
|
||||
case "refresh": {
|
||||
refresh();
|
||||
break;
|
||||
}
|
||||
case "reload": {
|
||||
reload();
|
||||
break;
|
||||
@@ -1274,7 +1281,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
filterStr: "",
|
||||
filterType: "content",
|
||||
placeholder: "",
|
||||
isFocused: false
|
||||
isFocused: false,
|
||||
});
|
||||
keysRef.current?.focus();
|
||||
}}
|
||||
|
||||
@@ -694,7 +694,7 @@ export const Explorer: FC = () => {
|
||||
console.log("editor move", editor.path === newPath, editor.path, newPath);
|
||||
if (editor.path.startsWith(newPath)) {
|
||||
console.log("editor reload", editor.path === newPath, editor.path, newPath);
|
||||
editor.dispatch("reload");
|
||||
editor.dispatch("refresh");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -133,7 +133,6 @@ export const Menu: FC<LayoutProps> = () => {
|
||||
accelerator: "CmdOrCtrl+S",
|
||||
enabled: enabled,
|
||||
click: () => {
|
||||
console.log("save1");
|
||||
workspace.save();
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user