aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-03-13 12:41:39 +0100
committerlain <lain@soykaf.club>2019-03-13 12:41:39 +0100
commit48ac96cfc7c9c3328d7a18707f00a2fe1bc743a1 (patch)
tree8076465bcfd26dc2444971d4a7e94b5cfd026764 /src
parent446785ddce5f78af7087a47d82f45633fc2f7da5 (diff)
afterStoreSetup: Handle 404 cases.
Diffstat (limited to 'src')
-rw-r--r--src/boot/after_store.js50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index f9e14eb2..a51f895e 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -7,28 +7,32 @@ import App from '../App.vue'
const getStatusnetConfig = async ({ store }) => {
try {
const res = await window.fetch('/api/statusnet/config.json')
- const data = await res.json()
- const { name, closed: registrationClosed, textlimit, uploadlimit, server, vapidPublicKey } = data.site
-
- store.dispatch('setInstanceOption', { name: 'name', value: name })
- store.dispatch('setInstanceOption', { name: 'registrationOpen', value: (registrationClosed === '0') })
- store.dispatch('setInstanceOption', { name: 'textlimit', value: parseInt(textlimit) })
- store.dispatch('setInstanceOption', { name: 'server', value: server })
-
- // TODO: default values for this stuff, added if to not make it break on
- // my dev config out of the box.
- if (uploadlimit) {
- store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadlimit.uploadlimit) })
- store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadlimit.avatarlimit) })
- store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadlimit.backgroundlimit) })
- store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadlimit.bannerlimit) })
- }
+ if (res.ok) {
+ const data = await res.json()
+ const { name, closed: registrationClosed, textlimit, uploadlimit, server, vapidPublicKey } = data.site
+
+ store.dispatch('setInstanceOption', { name: 'name', value: name })
+ store.dispatch('setInstanceOption', { name: 'registrationOpen', value: (registrationClosed === '0') })
+ store.dispatch('setInstanceOption', { name: 'textlimit', value: parseInt(textlimit) })
+ store.dispatch('setInstanceOption', { name: 'server', value: server })
+
+ // TODO: default values for this stuff, added if to not make it break on
+ // my dev config out of the box.
+ if (uploadlimit) {
+ store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadlimit.uploadlimit) })
+ store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadlimit.avatarlimit) })
+ store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadlimit.backgroundlimit) })
+ store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadlimit.bannerlimit) })
+ }
- if (vapidPublicKey) {
- store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey })
- }
+ if (vapidPublicKey) {
+ store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey })
+ }
- return data.site.pleromafe
+ return data.site.pleromafe
+ } else {
+ throw (res)
+ }
} catch (error) {
console.error('Could not load statusnet config, potentially fatal')
console.error(error)
@@ -38,7 +42,11 @@ const getStatusnetConfig = async ({ store }) => {
const getStaticConfig = async () => {
try {
const res = await window.fetch('/static/config.json')
- return res.json()
+ if (res.ok) {
+ return res.json()
+ } else {
+ throw (res)
+ }
} catch (error) {
console.warn('Failed to load static/config.json, continuing without it.')
console.warn(error)