mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-02 10:27:20 +01:00
Make config own function
This commit is contained in:
parent
7621be4198
commit
2397dd6b56
@ -4,6 +4,7 @@
|
||||
"logo": "logo.svg",
|
||||
"background": "background.png"
|
||||
},
|
||||
"developer": "true",
|
||||
"federated": "true",
|
||||
"registration": {
|
||||
"defaultInstance": "mastodon.social"
|
||||
|
@ -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);
|
||||
})
|
||||
|
@ -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<any, IWelcomeState> {
|
||||
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",
|
||||
|
@ -4,6 +4,7 @@ export type Config = {
|
||||
logo?: string;
|
||||
background?: string;
|
||||
};
|
||||
developer?: string;
|
||||
federated?: string;
|
||||
registration?: {
|
||||
defaultInstance?: string;
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user