31 lines
859 B
TypeScript
31 lines
859 B
TypeScript
import { useUserinfoStore } from "@/stores/UserinfoStore"
|
|
import { EngineContext } from '@/composables/useEngine'
|
|
import useAlert from '@/composables/useAlert'
|
|
|
|
export function start(this: EngineContext): 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
|
|
}
|
|
|
|
useAlert().clearAlert()
|
|
this.isActive = true
|
|
this.shouldStop = false
|
|
this.isConnected.value = true
|
|
|
|
this.fetchUpdate()
|
|
console.log('start engine')
|
|
}
|
|
|
|
export function stop(this: EngineContext): void {
|
|
if (this.isActive) {
|
|
useAlert().clearAlert()
|
|
this.shouldStop = true
|
|
this.isConnected.value = true
|
|
console.log('shut down engine')
|
|
}
|
|
} |