lock controls

This commit is contained in:
Craig
2020-02-11 23:51:57 +00:00
parent 605cb2778d
commit d29a64ac86
6 changed files with 134 additions and 32 deletions

View File

@ -1,6 +1,7 @@
import Vue from 'vue'
import Vuex from 'vuex'
import { useAccessor, mutationTree, actionTree } from 'typed-vuex'
import { EVENT } from '~/neko/events'
import { get, set } from '~/utils/localstorage'
import * as video from './video'
@ -51,6 +52,22 @@ export const actions = actionTree(
accessor.emoji.initialise()
},
lock() {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.LOCK)
},
unlock() {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.UNLOCK)
},
login({ state }, { username, password }: { username: string; password: string }) {
accessor.setLogin({ username, password })
$client.login(password, username)

View File

@ -8,6 +8,7 @@ export const namespaced = true
export const state = () => ({
id: '',
clipboard: '',
locked: false,
})
export const getters = getterTree(state, {
@ -35,9 +36,14 @@ export const mutations = mutationTree(state, {
state.clipboard = clipboard
},
setLocked(state, locked: boolean) {
state.locked = locked
},
reset(state) {
state.id = ''
state.clipboard = ''
state.locked = false
},
})
@ -127,21 +133,5 @@ export const actions = actionTree(
$client.sendMessage(EVENT.ADMIN.GIVE, { id: member.id })
},
lock() {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.LOCK)
},
unlock() {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.UNLOCK)
},
},
)