mirror of
https://github.com/nextcloud/integration_moodle.git
synced 2025-12-17 21:02:05 +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',
|
state: 'loading',
|
||||||
settingsUrl: generateUrl('/settings/user/connected-accounts'),
|
settingsUrl: generateUrl('/settings/user/connected-accounts'),
|
||||||
themingColor: OCA.Theming ? OCA.Theming.color.replace('#', '') : '0082C9',
|
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() {
|
beforeMount() {
|
||||||
this.launchLoop()
|
this.launchLoop()
|
||||||
|
document.addEventListener('visibilitychange', this.changeWindowVisibility)
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
changeWindowVisibility() {
|
||||||
|
this.windowVisibility = !document.hidden
|
||||||
|
},
|
||||||
|
stopLoop() {
|
||||||
|
clearInterval(this.loop)
|
||||||
|
},
|
||||||
async launchLoop() {
|
async launchLoop() {
|
||||||
// get moodle URL first
|
// get moodle URL first
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue