mtfosbot_web/src/store/mutations.js

28 lines
734 B
JavaScript

export default {
toggleLoading (state, loading = null) {
state.loading = !!loading
},
setUserInfo (state, {name, type}) {
if (typeof name !== 'string' || name.trim().length === 0) return
if (typeof type !== 'string' || type.trim().length === 0) return
name = name.trim()
type = type.trim()
state.user = {
...state.user,
name,
type
}
},
addDialog (state, {msg, act = null}) {
if (typeof msg !== 'string' || msg.trim().length === 0) return
state.dialog = [...state.dialog, {msg, act}]
},
removeDialog (state) {
state.dialog = state.dialog.slice(1)
},
setChannels (state, list) {
if (!Array.isArray(list)) return
state.twitch.channels = [...list]
}
}