Fix folder refresh debouncing
This commit is contained in:
parent
f0520ebbdc
commit
4326199454
|
|
@ -6,6 +6,6 @@ Its primary goal is to provide the user with a stack/column-based navigation his
|
||||||
## Features
|
## Features
|
||||||
- [x] Basic file editing
|
- [x] Basic file editing
|
||||||
- [x] Terminal integration
|
- [x] Terminal integration
|
||||||
- [x] File watching (note: slow!)
|
- [x] File watching
|
||||||
- [ ] Warn on exit when there are unsaved files
|
- [ ] Warn on exit when there are unsaved files
|
||||||
- [ ] LSP support
|
- [ ] LSP support
|
||||||
|
|
@ -15,7 +15,9 @@ async function openFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the current folder tree from main (re-open)
|
// Refresh the current folder tree from main (re-open)
|
||||||
|
let refreshScheduled = false;
|
||||||
async function refreshFolder() {
|
async function refreshFolder() {
|
||||||
|
refreshScheduled = false;
|
||||||
const folderTree = await window.electronAPI.getWorkspaceTree().catch(alert);
|
const folderTree = await window.electronAPI.getWorkspaceTree().catch(alert);
|
||||||
if (!folderTree) return;
|
if (!folderTree) return;
|
||||||
folderTreeState.val = folderTree;
|
folderTreeState.val = folderTree;
|
||||||
|
|
@ -36,7 +38,10 @@ window.electronAPI.onFsEvent(async (ev: { event: string; path: string }) => {
|
||||||
ev.event === "unlink"
|
ev.event === "unlink"
|
||||||
) {
|
) {
|
||||||
// Debounce-ish: schedule a refresh
|
// Debounce-ish: schedule a refresh
|
||||||
setTimeout(() => refreshFolder(), 50);
|
if(!refreshScheduled) {
|
||||||
|
refreshScheduled = true;
|
||||||
|
setTimeout(() => refreshFolder(), 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a file changed on disk and it's open, show disk version panels
|
// If a file changed on disk and it's open, show disk version panels
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue