knowyt/client/src/composables/engine/startStop.ts

25 lines
587 B
TypeScript
Raw Normal View History

import { useUserinfoStore } from "@/stores/UserinfoStore"
export function start(): void {
if (this.isActive && !this.shouldStop) {
console.warn('attempt to start already running engine!')
return
}
if (useUserinfoStore().isAdmin) {
console.debug('user is admin, engine not started')
return
}
this.isActive = true
this.shouldStop = false
this.fetchUpdate()
console.log('start engine')
}
export function stop(): void {
if (this.isActive) {
this.shouldStop = true
console.log('shut down engine')
}
}