diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-01-05 06:33:55 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-01-07 16:15:40 +0100 |
commit | 8aa2199f3dd47d8c8946843a2d93650547c73d99 (patch) | |
tree | 1d1ecec96e98e77fd449d85dd284bbb48cbbeb7a /src/components/LeftSidebar/SearchBox/SearchBox.vue | |
parent | 680567fa7f549d1e90a0fc698e0c80f157d150bd (diff) |
Fix leak of components due to EventBus event handlers
Several EventBus event handlers were registered in the components, but
never unregistered. Due to this even when the components were destroyed
the handlers were still active, so the references to the components
prevented them to be garbage collected.
Moreover, as the handlers were still active they were still called when
their associated event was triggered, which could cause for example an
infinite loop of requests to get new messages (as the store was
disconnected and thus the MessagesList component never got an updated
last known message ID, so it requested again and again new messages).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/components/LeftSidebar/SearchBox/SearchBox.vue')
-rw-r--r-- | src/components/LeftSidebar/SearchBox/SearchBox.vue | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/components/LeftSidebar/SearchBox/SearchBox.vue b/src/components/LeftSidebar/SearchBox/SearchBox.vue index 9f0b60eda..e32c263d8 100644 --- a/src/components/LeftSidebar/SearchBox/SearchBox.vue +++ b/src/components/LeftSidebar/SearchBox/SearchBox.vue @@ -73,9 +73,10 @@ export default { /** * Listen to routeChange global events and focus on the */ - EventBus.$on('routeChange', () => { - this.focusInput() - }) + EventBus.$on('routeChange', this.focusInput) + }, + beforeDestroy() { + EventBus.$off('routeChange', this.focusInput) }, methods: { // Focus the input field of the current componnent. |