Skip to content

Commit

Permalink
🩹 Stop status-check when Item is destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
marekful committed Jun 26, 2022
1 parent f9195ac commit 736f0e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/LinkItems/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ export default {
if (this.enableStatusCheck) this.checkWebsiteStatus();
// If continious status checking is enabled, then start ever-lasting loop
if (this.statusCheckInterval > 0) {
setInterval(this.checkWebsiteStatus, this.statusCheckInterval * 1000);
this.intervalId = setInterval(this.checkWebsiteStatus, this.statusCheckInterval * 1000);
}
},
beforeDestroy() {
// Stop periodic status-check when item is destroyed (e.g. navigating in multi-page setup)
if (this.intervalId) clearInterval(this.intervalId);
},
};
</script>

Expand Down
1 change: 1 addition & 0 deletions src/mixins/ItemMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
return {
statusResponse: undefined,
contextMenuOpen: false,
intervalId: undefined, // status-check setInterval() id
contextPos: {
posX: undefined,
posY: undefined,
Expand Down

0 comments on commit 736f0e9

Please sign in to comment.