Skip to content

Commit

Permalink
fix: stop health check poll when user logouts, fixes #229
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Nov 11, 2023
1 parent 0aef4a9 commit be83592
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Resources/app/administration/src/overrides/sw-version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit be83592

Please sign in to comment.