Fix project panel flicker and filter out directories

This commit is contained in:
Misode
2024-11-21 02:05:51 +01:00
parent 7719112b83
commit fa1f852822
2 changed files with 10 additions and 4 deletions

View File

@@ -27,13 +27,17 @@ export function ProjectPanel() {
const [entries, setEntries] = useState<string[]>()
useEffect(() => {
setEntries(undefined)
client.fs.readdir(projectRoot).then(entries => {
setEntries(entries.flatMap(e => {
return e.isFile() && e.name.startsWith(projectRoot) ? [e.name.slice(projectRoot.length)] : []
}))
})
}, [projectRoot])
useEffect(() => {
if (!service) {
return
}
service.watchTree(projectRoot, setEntries)
client.fs.readdir(projectRoot).then(entries => {
setEntries(entries.flatMap(e => e.isFile() && e.name.startsWith(projectRoot) ? [e.name.slice(projectRoot.length)] : []))
})
return () => service.unwatchTree(projectRoot, setEntries)
}, [service, projectRoot])