From 844448320d2d045956a7a0e1e1951eae16a1269a Mon Sep 17 00:00:00 2001 From: "Pierre Pulinckx (pipu)" Date: Fri, 6 Oct 2023 11:02:50 +0200 Subject: [PATCH] [FIX] web: fix bus of loading indicator We do not clean the event handlers properly (because we do .bind()). So we have another version of the handlers and they are not unbinded. In this commit, to remedy this, we use the useBus function which resolves this problem. closes odoo/odoo#137885 X-original-commit: 7e2e2e0b257d44ce051a3ee8f60e9e03f5d14739 Signed-off-by: Aaron Bohy (aab) --- .../webclient/loading_indicator/loading_indicator.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/webclient/loading_indicator/loading_indicator.js b/addons/web/static/src/webclient/loading_indicator/loading_indicator.js index fdd63fa9d9f..61a84fc9c10 100644 --- a/addons/web/static/src/webclient/loading_indicator/loading_indicator.js +++ b/addons/web/static/src/webclient/loading_indicator/loading_indicator.js @@ -2,10 +2,10 @@ import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; -import { useService } from "@web/core/utils/hooks"; +import { useBus, useService } from "@web/core/utils/hooks"; import { Transition } from "@web/core/transition"; -import { Component, onWillDestroy, useState } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; /** * Loading Indicator @@ -28,12 +28,8 @@ export class LoadingIndicator extends Component { this.shouldUnblock = false; this.startShowTimer = null; this.blockUITimer = null; - this.env.bus.addEventListener("RPC:REQUEST", this.requestCall.bind(this)); - this.env.bus.addEventListener("RPC:RESPONSE", this.responseCall.bind(this)); - onWillDestroy(() => { - this.env.bus.removeEventListener("RPC:REQUEST", this.requestCall.bind(this)); - this.env.bus.removeEventListener("RPC:RESPONSE", this.responseCall.bind(this)); - }); + useBus(this.env.bus, "RPC:REQUEST", this.requestCall); + useBus(this.env.bus, "RPC:RESPONSE", this.responseCall); } requestCall({ detail }) {