aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-08-26 21:25:59 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-08-26 21:25:59 +0200
commit8ab680e9648adf342d3dbd42cd0ebe02e31a00a8 (patch)
treeb419545dab6c2864641dd9ccc5d2188fb56c48b1 /src/api
parentLint (diff)
downloadferdium-app-8ab680e9648adf342d3dbd42cd0ebe02e31a00a8.tar.gz
ferdium-app-8ab680e9648adf342d3dbd42cd0ebe02e31a00a8.tar.zst
ferdium-app-8ab680e9648adf342d3dbd42cd0ebe02e31a00a8.zip
Improve apibase function
Diffstat (limited to 'src/api')
-rw-r--r--src/api/apiBase.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
index ce02922ac..b40673e44 100644
--- a/src/api/apiBase.js
+++ b/src/api/apiBase.js
@@ -8,9 +8,11 @@ import {
8 8
9const apiBase = () => { 9const apiBase = () => {
10 let url; 10 let url;
11
11 if (!window.ferdi 12 if (!window.ferdi
12 || !window.ferdi.stores.settings 13 || !window.ferdi.stores.settings
13 || !window.ferdi.stores.settings.all) { 14 || !window.ferdi.stores.settings.all
15 || !window.ferdi.stores.settings.all.app.server) {
14 // Stores have not yet been loaded - send invalid URL to force a retry when stores are loaded 16 // Stores have not yet been loaded - send invalid URL to force a retry when stores are loaded
15 // "Why 1.1.1.1 as the default, invalid URL?" 17 // "Why 1.1.1.1 as the default, invalid URL?"
16 // 1.1.1.1 is the server for Cloudflare's DNS service and will be the same across most networks. 18 // 1.1.1.1 is the server for Cloudflare's DNS service and will be the same across most networks.
@@ -20,12 +22,9 @@ const apiBase = () => {
20 // on some routes. This would result in Ferdi deleting its current authToken as it thinks it 22 // on some routes. This would result in Ferdi deleting its current authToken as it thinks it
21 // has gone invalid. 23 // has gone invalid.
22 url = 'https://1.1.1.1'; 24 url = 'https://1.1.1.1';
23 } else if (window.ferdi.stores.settings.all.app.server) { 25 } else {
24 // Load URL from store 26 // Load URL from store
25 url = window.ferdi.stores.settings.all.app.server; 27 url = window.ferdi.stores.settings.all.app.server;
26 } else {
27 // Use default server url
28 url = API;
29 } 28 }
30 29
31 return `${url}/${API_VERSION}`; 30 return `${url}/${API_VERSION}`;