Fix setInterval

This commit is contained in:
Matthias 2020-09-07 20:44:57 +02:00
parent ea60d1859a
commit b46e3e66a2
2 changed files with 8 additions and 8 deletions

View File

@ -14,9 +14,9 @@ import { Action, State } from 'vuex-class';
@Component({}) @Component({})
export default class ReloadControl extends Vue { export default class ReloadControl extends Vue {
refreshInterval: NodeJS.Timer | null = null; refreshInterval: number | null = null;
refreshIntervalSlow: NodeJS.Timer | null = null; refreshIntervalSlow: number | null = null;
created() { created() {
if (this.loggedIn) { if (this.loggedIn) {
@ -63,13 +63,13 @@ export default class ReloadControl extends Vue {
console.log('Starting automatic refresh.'); console.log('Starting automatic refresh.');
this.refreshFrequent(); this.refreshFrequent();
if (this.autoRefresh) { if (this.autoRefresh) {
this.refreshInterval = setInterval(() => { this.refreshInterval = window.setInterval(() => {
this.refreshFrequent(); this.refreshFrequent();
}, 5000); }, 5000);
} }
this.refreshSlow(); this.refreshSlow();
if (this.autoRefresh) { if (this.autoRefresh) {
this.refreshIntervalSlow = setInterval(() => { this.refreshIntervalSlow = window.setInterval(() => {
this.refreshSlow(); this.refreshSlow();
}, 60000); }, 60000);
} }
@ -78,10 +78,10 @@ export default class ReloadControl extends Vue {
stopRefresh() { stopRefresh() {
console.log('Stopping automatic refresh.'); console.log('Stopping automatic refresh.');
if (this.refreshInterval) { if (this.refreshInterval) {
clearInterval(this.refreshInterval); window.clearInterval(this.refreshInterval);
} }
if (this.refreshIntervalSlow) { if (this.refreshIntervalSlow) {
clearInterval(this.refreshIntervalSlow); window.clearInterval(this.refreshIntervalSlow);
} }
} }

View File

@ -55,7 +55,7 @@ const layoutNs = namespace('layout');
components: { LoginModal, BootswatchThemeSelect }, components: { LoginModal, BootswatchThemeSelect },
}) })
export default class NavBar extends Vue { export default class NavBar extends Vue {
pingInterval: NodeJS.Timer | null = null; pingInterval: number | null = null;
@State loggedIn!: boolean; @State loggedIn!: boolean;
@ -71,7 +71,7 @@ export default class NavBar extends Vue {
mounted() { mounted() {
this.ping(); this.ping();
this.pingInterval = setInterval(this.ping, 60000); this.pingInterval = window.setInterval(this.ping, 60000);
} }
beforeDestroy() { beforeDestroy() {