fix: remove router guard for unsaved category settings#664
Merged
ErikBjare merged 1 commit intoActivityWatch:masterfrom Apr 17, 2025
Merged
fix: remove router guard for unsaved category settings#664ErikBjare merged 1 commit intoActivityWatch:masterfrom
ErikBjare merged 1 commit intoActivityWatch:masterfrom
Conversation
In file [CategorizationSettings.vue](https://github.com/ActivityWatch/aw-webui/blob/cb9a7ecc58de8f4ffcc674deb44a52e10b2c6225/src/views/settings/CategorizationSettings.vue#L78) notes `// TODO: How to remove this listener?`
Contributor
There was a problem hiding this comment.
👍 Looks good to me! Reviewed everything up to 5d393f8 in 57 seconds
More details
- Looked at
32lines of code in1files - Skipped
0files when reviewing. - Skipped posting
6drafted comments based on config settings.
1. src/views/settings/CategorizationSettings.vue:64
- Draft comment:
Good: 'routerGuardRemover' is declared to store the removal function for the router guard. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%
None
2. src/views/settings/CategorizationSettings.vue:79
- Draft comment:
Assigning the router guard removal function to 'this.routerGuardRemover' ensures proper cleanup. Nice fix! - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%
None
3. src/views/settings/CategorizationSettings.vue:98
- Draft comment:
After calling the removal function in beforeDestroy, consider setting 'this.routerGuardRemover = null' for clarity. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%
None
4. src/views/settings/CategorizationSettings.vue:64
- Draft comment:
Initialized 'routerGuardRemover' in data is clear; consider renaming it (e.g. 'unregisterRouterGuard') to clarify its purpose. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%
None
5. src/views/settings/CategorizationSettings.vue:79
- Draft comment:
Assigning the return value of router.beforeEach to routerGuardRemover effectively captures the unregistration function. Verify that your router version returns an unregister function, as this behavior is available in Vue Router 4. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%
None
6. src/views/settings/CategorizationSettings.vue:98
- Draft comment:
The beforeDestroy hook correctly removes both the beforeunload listener and the router guard by invoking routerGuardRemover. Ensure that this cleanup works as expected in your router version. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%
None
Workflow ID: wflow_cOvV5FS0dM3uXsO7
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #664 +/- ##
=======================================
Coverage 26.76% 26.76%
=======================================
Files 28 28
Lines 1655 1655
Branches 292 292
=======================================
Hits 443 443
Misses 1155 1155
Partials 57 57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Very nice, thank you |
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.
In the file CategorizationSettings.vue, there is a note stating // TODO: How to remove this listener?.
This unresolved listener issue leads to an unintended behavior where the confirmation popup reappears every time the route changes, even if the initial confirmation popup was ignored.
This PR addresses the problem to ensure proper removal of the listener and prevent repeated popups during route changes.
Thanks in advance.
[BTW] This PR does resolve the aforementioned issue. However, I noticed that in
src/stores/categories.ts, the state ofclasses_unsaved_changesremainstrueeven after the confirmation popup is ignored, until the store'sload()action is called again.This behavior might lead to potential issues, but in line with the principle of minimal changes, I have not addressed this in this PR.
Important
Fixes repeated confirmation popup issue in
CategorizationSettings.vueby properly removing the router guard.CategorizationSettings.vueby properly removing the router guard.routerGuardRemoverand calls it inbeforeDestroy().routerGuardRemovertodatainCategorizationSettings.vue.This description was created by
for 5d393f8. It will automatically update as commits are pushed.