Refactor: Implement non-blocking async file operations and UI loading states - #19
Open
BradMoyetones wants to merge 1 commit into
Open
Refactor: Implement non-blocking async file operations and UI loading states#19BradMoyetones wants to merge 1 commit into
BradMoyetones wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the file system commands to prevent blocking the Tauri IPC threads, aligning with Tauri's best practices for I/O operations. It also introduces seamless loading states on the frontend to improve the UX during large file operations, without cluttering the global store.
Changes Made
src-tauri/src/commands.rs): Converted synchronous I/O commands (delete_entry,rename_entry,move_entry,create_note, etc.) toasync fn. Wrapped the underlying filesystem calls usingtauri::async_runtime::spawn_blockingto offload them to a background thread pool, preventing any potential UI or IPC freezes.src/stores/vault.ts): Wrapped the correspondingipccalls in promises and implementedtoast.promisefrom Sonner. This natively providesloading,success, anderrortoast notifications immediately when interacting with the vault (e.g. moving to trash, renaming) without the need to introduce additional loading state variables into the UI components.Motivation
To ensure the application remains highly responsive and doesn't limit performance on modern hardware when handling large vaults or heavy OS-level operations.