Unregister notification handlers.

When leaving the Project component, all its notification handlers
will be unregistered, otherwise we end up with a memory leak.
This commit is contained in:
D. Berge
2025-08-08 12:22:56 +02:00
parent b583dc6c02
commit 5a19c81ed1

View File

@@ -85,10 +85,10 @@ export default {
this.refreshSequences(); this.refreshSequences();
}, },
registerNotificationHandlers () { registerNotificationHandlers (action = "registerHandler") {
this.$store.dispatch('registerHandler', { this.$store.dispatch(action, {
table: 'event', table: 'event',
handler: (context, message) => { handler: (context, message) => {
@@ -97,7 +97,7 @@ export default {
}); });
["preplot_lines", "preplot_points"].forEach( table => { ["preplot_lines", "preplot_points"].forEach( table => {
this.$store.dispatch('registerHandler', { this.$store.dispatch(action, {
table, table,
handler: (context, message) => { handler: (context, message) => {
@@ -107,7 +107,7 @@ export default {
}); });
this.$store.dispatch('registerHandler', { this.$store.dispatch(action, {
table: 'planned_lines', table: 'planned_lines',
handler: (context, message) => { handler: (context, message) => {
@@ -116,7 +116,7 @@ export default {
}); });
["raw_lines", "raw_shots", "final_lines", "final_shots"].forEach( table => { ["raw_lines", "raw_shots", "final_lines", "final_shots"].forEach( table => {
this.$store.dispatch('registerHandler', { this.$store.dispatch(action, {
table, table,
handler: (context, message) => { handler: (context, message) => {
@@ -127,6 +127,10 @@ export default {
}, },
unregisterNotificationHandlers () {
return this.registerNotificationHandlers("unregisterHandler");
},
...mapActions(["getProject", "refreshLines", "refreshSequences", "refreshEvents", "refreshLabels", "refreshPlan"]) ...mapActions(["getProject", "refreshLines", "refreshSequences", "refreshEvents", "refreshLabels", "refreshPlan"])
}, },
@@ -141,7 +145,12 @@ export default {
this.refreshLabels(); this.refreshLabels();
this.refreshPlan(); this.refreshPlan();
} }
},
beforeDestroy () {
this.unregisterNotificationHandlers();
} }
} }
</script> </script>