mirror of
https://github.com/nextcloud/integration_moodle.git
synced 2025-12-17 12:58:30 +01:00
stop polling widget content when document is hidden
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
parent
d4f1abe3e2
commit
9fd4a6ab34
1 changed files with 22 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ export default {
|
|||
state: 'loading',
|
||||
settingsUrl: generateUrl('/settings/user/connected-accounts'),
|
||||
themingColor: OCA.Theming ? OCA.Theming.color.replace('#', '') : '0082C9',
|
||||
windowVisibility: true,
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -112,14 +113,35 @@ export default {
|
|||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
windowVisibility(newValue) {
|
||||
if (newValue) {
|
||||
this.launchLoop()
|
||||
} else {
|
||||
this.stopLoop()
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
document.removeEventListener('visibilitychange', this.changeWindowVisibility)
|
||||
},
|
||||
|
||||
beforeMount() {
|
||||
this.launchLoop()
|
||||
document.addEventListener('visibilitychange', this.changeWindowVisibility)
|
||||
},
|
||||
|
||||
mounted() {
|
||||
},
|
||||
|
||||
methods: {
|
||||
changeWindowVisibility() {
|
||||
this.windowVisibility = !document.hidden
|
||||
},
|
||||
stopLoop() {
|
||||
clearInterval(this.loop)
|
||||
},
|
||||
async launchLoop() {
|
||||
// get moodle URL first
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue