diff --git a/stores/misc.js b/stores/misc.js index 5167e83d..2a210b0d 100644 --- a/stores/misc.js +++ b/stores/misc.js @@ -94,35 +94,37 @@ export const useMiscStore = defineStore({ } }, async checkOnline() { - try { - const response = await this.fetchWithTimeout( - this.config.public.APIv2 + '/online', - null, - 5000 - ) + if (this.visible) { + try { + const response = await this.fetchWithTimeout( + this.config.public.APIv2 + '/online', + null, + 5000 + ) - if (response?.status === 200) { - const rsp = await response.json() + if (response?.status === 200) { + const rsp = await response.json() - if (!this.online) { - console.log('Back online') - this.online = rsp.online + if (!this.online) { + console.log('Back online') + this.online = rsp.online + } + } else { + // Null response happens when we time out + console.log('Offline', response) + this.online = false + } + } catch (e) { + if (this.online) { + console.log('Gone offline', e) + this.online = false } - } else { - // Null response happens when we time out - console.log('Offline', response) - this.online = false - } - } catch (e) { - if (this.online) { - console.log('Gone offline', e) - this.online = false } } this.onlineTimer = setTimeout( this.checkOnline, - this.visible ? 1000 : 30000 + 1000 ) }, waitForOnline() {