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

25 lines
623 B
TypeScript
Raw Normal View History

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