summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-23 20:00:27 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-23 20:00:27 +1100
commit431918b75253292e03fda49afcdb1c555af9e086 (patch)
tree36b1dc7c76d69067f9c43b15ca6e95a9391d359d /src/utils
parentschemes: fix previews not updating (diff)
downloadcaelestia-shell-431918b75253292e03fda49afcdb1c555af9e086.tar.gz
caelestia-shell-431918b75253292e03fda49afcdb1c555af9e086.tar.bz2
caelestia-shell-431918b75253292e03fda49afcdb1c555af9e086.zip
schemes: fix updating taking ages
Cause it was being called for every file change So instead of updating all, just update changed Also async update all
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/system.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/utils/system.ts b/src/utils/system.ts
index 518fb9a..2e9fa4a 100644
--- a/src/utils/system.ts
+++ b/src/utils/system.ts
@@ -76,10 +76,21 @@ export const bindCurrentTime = (
return bind(time);
};
-export const monitorDirectory = (path: string, callback: (path: string) => void, recursive?: boolean) => {
+export const monitorDirectory = (
+ path: string,
+ callback: (
+ source: Gio.FileMonitor,
+ file: Gio.File,
+ other_file: Gio.File | null,
+ type: Gio.FileMonitorEvent
+ ) => void,
+ recursive: boolean = true
+) => {
const file = Gio.file_new_for_path(path.replace("~", HOME));
- const monitor = file.monitor_directory(Gio.FileMonitorFlags.WATCH_MOUNTS | Gio.FileMonitorFlags.WATCH_MOVES, null);
- monitor.connect("changed", callback);
+ const monitor = file.monitor_directory(null, null);
+ monitor.connect("changed", (m, f1, f2, t) => {
+ if (t === Gio.FileMonitorEvent.CHANGES_DONE_HINT || t === Gio.FileMonitorEvent.DELETED) callback(m, f1, f2, t);
+ });
if (recursive) {
const enumerator = file.enumerate_children("standard::*", null, null);