Skip to content

Commit 9842d3e

Browse files
fix: remove router guard for unsaved category settings (#664)
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?`
1 parent 4334c03 commit 9842d3e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/views/settings/CategorizationSettings.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default {
6161
data: () => ({
6262
categoryStore: useCategoryStore(),
6363
editingId: null,
64+
routerGuardRemover: null,
6465
}),
6566
computed: {
6667
...mapState(useCategoryStore, ['classes_unsaved_changes']),
@@ -75,8 +76,7 @@ export default {
7576
// beforeEach hook
7677
window.addEventListener('beforeunload', this.beforeUnload);
7778
78-
// TODO: How to remove this listener?
79-
router.beforeEach((to, from, next) => {
79+
this.routerGuardRemover = router.beforeEach((to, from, next) => {
8080
try {
8181
if (this.classes_unsaved_changes) {
8282
if (confirm(confirmationMessage)) {
@@ -95,6 +95,9 @@ export default {
9595
},
9696
beforeDestroy() {
9797
window.removeEventListener('beforeunload', this.beforeUnload);
98+
if (this.routerGuardRemover) {
99+
this.routerGuardRemover();
100+
}
98101
},
99102
methods: {
100103
addClass: function () {

0 commit comments

Comments
 (0)