From f7bd710fc0654b534142675f8e5ad0b209d0f46a Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Mon, 2 Dec 2019 17:14:49 +0100 Subject: [PATCH] Settings and api preload --- src/services/Server.js | 3 +++ src/store/store.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/services/Server.js b/src/services/Server.js index 623d0965..5a3aa6be 100644 --- a/src/services/Server.js +++ b/src/services/Server.js @@ -13,6 +13,9 @@ export default { }, getAPIUrl () { return new Promise((resolve, reject) => { + if(localStorage.getItem("apiURL")) { + resolve(); + } axios.get('/apiurl') .then(function (response) { // handle success diff --git a/src/store/store.js b/src/store/store.js index c5e960ba..483a5ce2 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -71,12 +71,18 @@ export default new Vuex.Store({ actions: { getSettings: function (context) { return new Promise((resolve, reject) => { + if(localStorage.getItem("settings")) { + context.commit('setSettings', localStorage.getItem("settings")) + resolve(); + } ServerService.getPublicSettings().then((res) => { + localStorage.setItem("settings", res.data.data) context.commit('setSettings', res.data.data) resolve() }).catch((res) => { context.commit('setError') }); + }) }, checkAccount: function(context) {