neko/client/src/store/remote.ts

38 lines
728 B
TypeScript
Raw Normal View History

2020-01-21 03:36:18 +13:00
import { getterTree, mutationTree, actionTree } from 'typed-vuex'
import { Member } from '~/client/types'
export const namespaced = true
export const state = () => ({
id: '',
})
export const getters = getterTree(state, {
hosting: (state, getters, root) => {
return root.user.id === state.id
},
host: (state, getters, root) => {
return root.user.member[state.id] || null
},
})
export const mutations = mutationTree(state, {
clearHost(state) {
state.id = ''
},
setHost(state, host: string | Member) {
if (typeof host === 'string') {
state.id = host
} else {
state.id = host.id
}
},
})
export const actions = actionTree(
{ state, getters, mutations },
{
//
},
)