mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Fix project panel flicker and filter out directories
This commit is contained in:
@@ -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])
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ export class SpyglassService {
|
||||
await new Promise((res) => setTimeout(res, 5))
|
||||
await Promise.all(this.treeWatchers.map(async ({ prefix, handler }) => {
|
||||
const entries = await client.fs.readdir(prefix)
|
||||
handler(entries.flatMap(e => e.name.startsWith(prefix) ? [e.name.slice(prefix.length)] : []))
|
||||
handler(entries.flatMap(e => {
|
||||
return e.isFile() && e.name.startsWith(prefix) ? [e.name.slice(prefix.length)] : []
|
||||
}))
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user