mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
move filetransfer to locks.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import { useAccessor, mutationTree, actionTree } from 'typed-vuex'
|
||||
import { useAccessor, mutationTree, getterTree, actionTree } from 'typed-vuex'
|
||||
import { EVENT } from '~/neko/events'
|
||||
import { AdminLockResource } from '~/neko/messages'
|
||||
import { get, set } from '~/utils/localstorage'
|
||||
@ -56,8 +56,12 @@ export const mutations = mutationTree(state, {
|
||||
},
|
||||
})
|
||||
|
||||
export const getters = getterTree(state, {
|
||||
isLocked: (state) => (resource: AdminLockResource) => resource in state.locked && state.locked[resource],
|
||||
})
|
||||
|
||||
export const actions = actionTree(
|
||||
{ state, mutations },
|
||||
{ state, getters, mutations },
|
||||
{
|
||||
initialise(store) {
|
||||
accessor.emoji.initialise()
|
||||
@ -80,6 +84,14 @@ export const actions = actionTree(
|
||||
$client.sendMessage(EVENT.ADMIN.UNLOCK, { resource })
|
||||
},
|
||||
|
||||
toggleLock(_, resource: AdminLockResource) {
|
||||
if (accessor.isLocked(resource)) {
|
||||
accessor.unlock(resource)
|
||||
} else {
|
||||
accessor.lock(resource)
|
||||
}
|
||||
},
|
||||
|
||||
login({ state }, { displayname, password }: { displayname: string; password: string }) {
|
||||
accessor.setLogin({ displayname, password })
|
||||
$client.login(password, displayname)
|
||||
@ -98,6 +110,7 @@ export const storePattern = {
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters,
|
||||
modules: { video, chat, files, user, remote, settings, client, emoji },
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ export const state = () => ({
|
||||
clipboard: '',
|
||||
locked: false,
|
||||
implicitHosting: true,
|
||||
fileTransfer: true,
|
||||
keyboardModifierState: -1,
|
||||
})
|
||||
|
||||
@ -53,6 +54,10 @@ export const mutations = mutationTree(state, {
|
||||
state.implicitHosting = val
|
||||
},
|
||||
|
||||
setFileTransfer(state, val: boolean) {
|
||||
state.fileTransfer = val
|
||||
},
|
||||
|
||||
reset(state) {
|
||||
state.id = ''
|
||||
state.clipboard = ''
|
||||
|
@ -20,9 +20,6 @@ export const state = () => {
|
||||
|
||||
keyboard_layouts_list: {} as KeyboardLayouts,
|
||||
|
||||
file_transfer: false,
|
||||
unpriv_file_transfer: false,
|
||||
|
||||
broadcast_is_active: false,
|
||||
broadcast_url: '',
|
||||
}
|
||||
@ -61,14 +58,6 @@ export const mutations = mutationTree(state, {
|
||||
set('keyboard_layout', value)
|
||||
},
|
||||
|
||||
setFileTransfer(state, value: boolean) {
|
||||
state.file_transfer = value
|
||||
},
|
||||
|
||||
setUnprivFileTransfer(state, value: boolean) {
|
||||
state.unpriv_file_transfer = value
|
||||
},
|
||||
|
||||
setKeyboardLayoutsList(state, value: KeyboardLayouts) {
|
||||
state.keyboard_layouts_list = value
|
||||
},
|
||||
@ -90,22 +79,6 @@ export const actions = actionTree(
|
||||
}
|
||||
},
|
||||
|
||||
setLocalFileTransferStatus({ getters }, { admin, unpriv }) {
|
||||
accessor.settings.setFileTransfer(admin)
|
||||
accessor.settings.setUnprivFileTransfer(unpriv)
|
||||
|
||||
if (!admin || (!accessor.user.admin && !unpriv)) {
|
||||
accessor.files.cancelAllTransfers()
|
||||
}
|
||||
|
||||
if (accessor.client.tab === 'files' && !unpriv) {
|
||||
accessor.client.setTab('chat')
|
||||
}
|
||||
},
|
||||
setRemoteFileTransferStatus({ getters }, { admin, unpriv }) {
|
||||
$client.sendMessage(EVENT.FILETRANSFER.STATUS, { admin, unpriv })
|
||||
},
|
||||
|
||||
broadcastStatus({ getters }, { url, isActive }) {
|
||||
accessor.settings.setBroadcastStatus({ url, isActive })
|
||||
},
|
||||
|
Reference in New Issue
Block a user