Skip to content

Commit 07c0406

Browse files
feat(app): make the app watch for external file system
1 parent 4c3537a commit 07c0406

3 files changed

Lines changed: 129 additions & 5 deletions

File tree

apps/app/src-tauri/Cargo.lock

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app/src-tauri/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ serde = { version = "1.0", features = ["derive"] }
2626
log = "0.4"
2727
tauri = { version = "2.10.2", features = [] }
2828
tauri-plugin-log = "2"
29-
tauri-plugin-fs = "2"
29+
tauri-plugin-fs = { version = "2", features = ['watch'] }
3030
tauri-plugin-store = "2"
3131
tauri-plugin-dialog = "2"
3232
tauri-plugin-os = "2"
@@ -43,7 +43,7 @@ incremental = true # Compile your binary in smaller steps.
4343

4444
[profile.release]
4545
codegen-units = 1 # Allows LLVM to perform better optimization.
46-
lto = true # Enables link-time-optimizations.
47-
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
48-
panic = "abort" # Higher performance by disabling panic handlers.
49-
strip = true # Ensures debug symbols are removed.
46+
lto = true # Enables link-time-optimizations.
47+
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
48+
panic = "abort" # Higher performance by disabling panic handlers.
49+
strip = true # Ensures debug symbols are removed.

apps/app/src/components/general/root_folder_selector/operations.svelte.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
file_tree,
1717
is_filetree_loading,
1818
} from '@/components/sidebar_section/file_manager/states.svelte';
19+
import { watch } from '@tauri-apps/plugin-fs';
1920

2021
export const user_activity = new LazyStore('user_activity.json');
2122
export let recent_workspaces: { data: Workspace[] } = $state({ data: [] });
@@ -37,6 +38,27 @@ export async function update_workspace(
3738
workspace_root_path.data = generic_path;
3839
is_filetree_loading.data = true;
3940
file_tree.data = await build_file_tree_from_fs(generic_path);
41+
watch(
42+
generic_path.path,
43+
async (e) => {
44+
// do nothing if all that happened is:
45+
// - a file was accessed
46+
// - a file's content was modified
47+
const event_type = e.type;
48+
if (
49+
typeof event_type == 'object' &&
50+
('access' in event_type ||
51+
('modify' in event_type && event_type.modify.kind !== 'rename'))
52+
)
53+
return;
54+
console.log('Stuff CHanged', e);
55+
file_tree.data = await build_file_tree_from_fs(generic_path);
56+
},
57+
{
58+
recursive: true,
59+
delayMs: 300,
60+
}
61+
);
4062
is_filetree_loading.data = false;
4163
update_opened_filenode(last_filenode_path, generic_path.path);
4264
if (current_platform == 'android') {

0 commit comments

Comments
 (0)