Store for instance events

This commit is contained in:
Eliot Berriot 2018-03-02 00:13:45 +01:00
parent 40350f0555
commit e319f5933e
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
2 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,10 @@ export default new Vuex.Store({
return mutation.type.startsWith('auth/') return mutation.type.startsWith('auth/')
} }
}), }),
createPersistedState({
key: 'instance',
paths: ['instance.events']
}),
createPersistedState({ createPersistedState({
key: 'radios', key: 'radios',
paths: ['radios'], paths: ['radios'],

View File

@ -5,6 +5,8 @@ import _ from 'lodash'
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
maxEvents: 200,
events: [],
settings: { settings: {
instance: { instance: {
name: { name: {
@ -35,6 +37,12 @@ export default {
mutations: { mutations: {
settings: (state, value) => { settings: (state, value) => {
_.merge(state.settings, value) _.merge(state.settings, value)
},
event: (state, value) => {
state.events.unshift(value)
if (state.events.length > state.maxEvents) {
state.events = state.events.slice(0, state.maxEvents)
}
} }
}, },
actions: { actions: {