Skip to content

Commit

Permalink
Fix: only trigger save-file-tree when folder changes
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantk232 authored and amitu committed Oct 6, 2024
1 parent bd5a448 commit e68d038
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/editor/editor-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/editor/editor-bundle.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions components/editor/panels/package/package-content.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as ftd2 from "../../ftd2";
import * as preact from "preact";
import { useEffect } from "preact/hooks";

const ROOT_ID = "package-content-placeholder";
const ROOT_DATA = "outer-folder";
Expand Down Expand Up @@ -85,8 +86,10 @@ function show_package_content({folders, files, ftd_root}) {
let modified_files = new ftd2.FastnTik([], ftd_root, MODIFIED_FILES).get();
let only_modified_files = new ftd2.FastnTik(false, ftd_root, ONLY_MODIFIED_FILES).get();

// saves open file state on every render
window.dispatchEvent(new CustomEvent("ide-event", {detail: {name: "save-file-tree", data: folder.get()}}));
useEffect(() => {
// saves open file state on every render
window.dispatchEvent(new CustomEvent("ide-event", {detail: {name: "save-file-tree", data: folder.get()}}));
}, [folder.get()]);

return preact.h(
show_folder, {
Expand Down

0 comments on commit e68d038

Please sign in to comment.