diff --git a/public/config.json b/public/config.json index 2dcbdc9..8265e62 100644 --- a/public/config.json +++ b/public/config.json @@ -4,6 +4,7 @@ "logo": "logo.svg", "background": "background.png" }, + "developer": "true", "federated": "true", "registration": { "defaultInstance": "mastodon.social" diff --git a/src/index.tsx b/src/index.tsx index ed31b66..87801c9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,14 +3,13 @@ import ReactDOM from 'react-dom'; import App from './App'; import { HashRouter } from 'react-router-dom'; import * as serviceWorker from './serviceWorker'; -import {createUserDefaults} from './utilities/settings'; +import {createUserDefaults, getConfig} from './utilities/settings'; import {collectEmojisFromServer} from './utilities/emojis'; import {SnackbarProvider} from 'notistack'; -import axios from 'axios'; import { userLoggedIn, refreshUserAccountData } from './utilities/accounts'; -axios.get('config.json').then((resp: any) => { - document.title = resp.data.branding.name || "Hyperspace"; +getConfig().then((config: any) => { + document.title = config.branding.name || "Hyperspace"; }).catch((err: Error) => { console.error(err); }) diff --git a/src/pages/Welcome.tsx b/src/pages/Welcome.tsx index d01e0b5..4c728ff 100644 --- a/src/pages/Welcome.tsx +++ b/src/pages/Welcome.tsx @@ -7,6 +7,7 @@ import {Config} from '../types/Config'; import {SaveClientSession} from '../types/SessionData'; import { createHyperspaceApp } from '../utilities/login'; import {parseUrl} from 'query-string'; +import { getConfig } from '../utilities/settings'; interface IWelcomeState { logoUrl?: string; @@ -39,9 +40,7 @@ class WelcomePage extends Component { authority: false } - axios.get('config.json').then((resp: any) => { - let result: Config = resp.data; - + getConfig().then((result: any) => { this.setState({ logoUrl: result.branding? result.branding.logo: "logo.png", backgroundUrl: result.branding? result.branding.background: "background.png", diff --git a/src/types/Config.tsx b/src/types/Config.tsx index 5b8b341..c7cf602 100644 --- a/src/types/Config.tsx +++ b/src/types/Config.tsx @@ -4,6 +4,7 @@ export type Config = { logo?: string; background?: string; }; + developer?: string; federated?: string; registration?: { defaultInstance?: string; diff --git a/src/utilities/settings.tsx b/src/utilities/settings.tsx index d445b32..0bbd5b3 100644 --- a/src/utilities/settings.tsx +++ b/src/utilities/settings.tsx @@ -1,5 +1,7 @@ import { defaultTheme, themes } from "../types/HyperspaceTheme"; import { getNotificationRequestPermission } from './notifications'; +import axios from 'axios'; +import { Config } from "../types/Config"; type SettingsTemplate = { [key:string]: any; @@ -72,4 +74,13 @@ export function createUserDefaults() { } }) getNotificationRequestPermission(); +} + +export function getConfig() { + return axios.get('config.json').then((resp: any) => { + let config: Config = resp.data; + return config; + }).catch((err: Error) => { + console.error("Couldn't configure Hyperspace with the config file. Reason: " + err.name) + }) } \ No newline at end of file