From 370468bd6aadd31b9c254bde87af2f9eaeb06c0b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 14 Feb 2017 22:42:13 +0100 Subject: [PATCH] Persist users. --- package.json | 3 ++- src/main.js | 9 ++++++++- yarn.lock | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38321134..437ad57f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "vue": "^2.0.1", "vue-router": "^2.0.1", "vue-timeago": "^3.1.2", - "vuex": "^2.0.0" + "vuex": "^2.0.0", + "vuex-persistedstate": "^1.1.0" }, "devDependencies": { "autoprefixer": "^6.4.0", diff --git a/src/main.js b/src/main.js index fb48a64d..84db5c86 100644 --- a/src/main.js +++ b/src/main.js @@ -16,6 +16,8 @@ import configModule from './modules/config.js' import VueTimeago from 'vue-timeago' +import createPersistedState from 'vuex-persistedstate' + Vue.use(Vuex) Vue.use(VueRouter) Vue.use(VueTimeago, { @@ -25,13 +27,18 @@ Vue.use(VueTimeago, { } }) +const persistedStateOptions = { + paths: ['users.users'] +} + const store = new Vuex.Store({ modules: { statuses: statusesModule, users: usersModule, api: apiModule, config: configModule - } + }, + plugins: [createPersistedState(persistedStateOptions)] }) const routes = [ diff --git a/yarn.lock b/yarn.lock index 16150613..a1ce6b64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3495,6 +3495,10 @@ lodash.merge@^3.3.2: lodash.keysin "^3.0.0" lodash.toplainobject "^3.0.0" +lodash.merge@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" + lodash.pairs@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash.pairs/-/lodash.pairs-3.0.1.tgz#bbe08d5786eeeaa09a15c91ebf0dcb7d2be326a9" @@ -4011,6 +4015,10 @@ object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" +object-path@^0.11.2: + version "0.11.3" + resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.11.3.tgz#3e21a42ad07234d815429ae9e15c1c5f38050554" + object.omit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.0.tgz#868597333d54e60662940bb458605dd6ae12fe94" @@ -5734,6 +5742,13 @@ vuex: version "2.0.0" resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.0.0.tgz#26befa44de220f009e432d1027487bff29571cee" +vuex-persistedstate: + version "1.1.0" + resolved "https://registry.yarnpkg.com/vuex-persistedstate/-/vuex-persistedstate-1.1.0.tgz#94f2e94a873f39fc716dea3129af45df8d4d6f78" + dependencies: + lodash.merge "^4.6.0" + object-path "^0.11.2" + watchpack@^0.2.1: version "0.2.9" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-0.2.9.tgz#62eaa4ab5e5ba35fdfc018275626e3c0f5e3fb0b"