Skip to content

Commit

Permalink
feat: loadfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Aug 29, 2024
1 parent 566c806 commit 51e56d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions components/webcontainer/node-terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FitAddon } from "@xterm/addon-fit";
import { WebContainer } from "@webcontainer/api";
import { useWebContainer } from "./use-web-container";
import { useTheme } from "next-themes";
import { useLoadFiles } from "./use-load-files";

async function startShell(
terminal: Terminal,
Expand Down Expand Up @@ -45,6 +46,7 @@ export function NodeTerminal() {
const terminalRef = useRef<Terminal>();
const webContainer = useWebContainer();
const { resolvedTheme } = useTheme();
const loadFiles = useLoadFiles();

useEffect(() => {
if (!!terminalElRef.current && !terminalRef.current && !!webContainer) {
Expand Down Expand Up @@ -82,6 +84,10 @@ export function NodeTerminal() {
}
}, [resolvedTheme, terminalRef]);

useEffect(() => {
loadFiles();
}, [loadFiles]);

return <div ref={terminalElRef} className="p-2"></div>;
}

Expand Down
2 changes: 1 addition & 1 deletion components/webcontainer/use-load-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useLoadFiles() {
});
webContainer.mount(root);
}
}, [id, pathname]);
}, [id, pathname, webContainer]);

return loadFiles;
}
2 changes: 1 addition & 1 deletion components/workspace/upload-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function UploadModal() {
);

await refreshFileExplorer();
loadFiles();
await loadFiles();
setIsOpen(false);
} catch (err) {
alert(String(err));
Expand Down

0 comments on commit 51e56d6

Please sign in to comment.