From be8359280750f0589c5c69bd05de69aacf9d3afb Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sat, 11 Nov 2023 18:50:01 +0100 Subject: [PATCH] fix: stop health check poll when user logouts, fixes #229 --- .../src/overrides/sw-version/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Resources/app/administration/src/overrides/sw-version/index.js b/src/Resources/app/administration/src/overrides/sw-version/index.js index 1f40411..3d868e7 100644 --- a/src/Resources/app/administration/src/overrides/sw-version/index.js +++ b/src/Resources/app/administration/src/overrides/sw-version/index.js @@ -4,13 +4,13 @@ const { Component } = Shopware; Component.override('sw-version', { template, - inject: ['froshToolsService', 'acl'], + inject: ['froshToolsService', 'acl', 'loginService'], async created() { if(!this.checkPermission()) { return; } - + await this.checkHealth(); }, @@ -65,9 +65,16 @@ Component.override('sw-version', { async checkHealth() { this.health = await this.froshToolsService.healthStatus(); - setInterval(async() => { - this.health = await this.froshToolsService.healthStatus(); + this.checkInterval = setInterval(async() => { + try { + this.health = await this.froshToolsService.healthStatus(); + } catch (e) { + console.error(e); + clearInterval(this.checkInterval); + } }, 30000); + + this.loginService.addOnLogoutListener(() => clearInterval(this.checkInterval)); }, checkPermission() {