From e319f5933e39bd76a57c953a7091c96a337d9d44 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Fri, 2 Mar 2018 00:13:45 +0100
Subject: [PATCH] Store for instance events

---
 front/src/store/index.js    | 4 ++++
 front/src/store/instance.js | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/front/src/store/index.js b/front/src/store/index.js
index e111966a..2453c0e7 100644
--- a/front/src/store/index.js
+++ b/front/src/store/index.js
@@ -30,6 +30,10 @@ export default new Vuex.Store({
         return mutation.type.startsWith('auth/')
       }
     }),
+    createPersistedState({
+      key: 'instance',
+      paths: ['instance.events']
+    }),
     createPersistedState({
       key: 'radios',
       paths: ['radios'],
diff --git a/front/src/store/instance.js b/front/src/store/instance.js
index a4dfcada..2436eab0 100644
--- a/front/src/store/instance.js
+++ b/front/src/store/instance.js
@@ -5,6 +5,8 @@ import _ from 'lodash'
 export default {
   namespaced: true,
   state: {
+    maxEvents: 200,
+    events: [],
     settings: {
       instance: {
         name: {
@@ -35,6 +37,12 @@ export default {
   mutations: {
     settings: (state, 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: {
-- 
GitLab