Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add show manager shortcut plus refactoring #419

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

Charlie-XIAO
Copy link
Contributor

@Charlie-XIAO Charlie-XIAO commented Feb 13, 2025

Extracted from and refactored upon #370.

This PR does the following:

  • Add a show_manager shortcut for showing (and focusing) the manager window.
  • Refactor shortcuts.rs, making a better macro to generate the implementations. Now each time there are only two places to modify in the backend: add an entry for Shortcuts in settings.rs, then add a key => listener pair in impl_shortcuts! in shortcuts.rs, and two places in the frontend: add the entry for Shortcuts in types/backend/settings.ts, then make the UI in manager/components/Settings/index.tsx.
  • Replaced bincode with serde_json for the settings file. The reason is that, bincode seems to do well only when the structure for deserialization is not broken, otherwise bincode may directly panic (due to excessive memory allocation, etc). Why this happens? We may change the settings structure between versions. For adding fields we can put #[serde(default)] to avoid errors. For removing field, serde_json automatically ignores redundant stuff (it seems so). For changing fields, we can make some kind of deprecation cycle. bincode does not seem to be flexible enough when dealing with these. Also our settings won't be so huge that serialization/deserialization performance differ a lot, so settings.json would be just fine.

@Charlie-XIAO Charlie-XIAO merged commit 53aace8 into main Feb 13, 2025
11 checks passed
@Charlie-XIAO Charlie-XIAO deleted the refactor/shortcuts-show-manager branch February 13, 2025 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant