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

27 lines
663 B
TypeScript

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.isConnected.value = true
this.fetchUpdate()
console.log('start engine')
}
export function stop(): void {
if (this.isActive) {
this.shouldStop = true
this.isConnected.value = true
console.log('shut down engine')
}
}