mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-09 00:08:52 +01:00
Make config own function
This commit is contained in:
parent
7621be4198
commit
2397dd6b56
@ -4,6 +4,7 @@
|
|||||||
"logo": "logo.svg",
|
"logo": "logo.svg",
|
||||||
"background": "background.png"
|
"background": "background.png"
|
||||||
},
|
},
|
||||||
|
"developer": "true",
|
||||||
"federated": "true",
|
"federated": "true",
|
||||||
"registration": {
|
"registration": {
|
||||||
"defaultInstance": "mastodon.social"
|
"defaultInstance": "mastodon.social"
|
||||||
|
@ -3,14 +3,13 @@ import ReactDOM from 'react-dom';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
import { HashRouter } from 'react-router-dom';
|
import { HashRouter } from 'react-router-dom';
|
||||||
import * as serviceWorker from './serviceWorker';
|
import * as serviceWorker from './serviceWorker';
|
||||||
import {createUserDefaults} from './utilities/settings';
|
import {createUserDefaults, getConfig} from './utilities/settings';
|
||||||
import {collectEmojisFromServer} from './utilities/emojis';
|
import {collectEmojisFromServer} from './utilities/emojis';
|
||||||
import {SnackbarProvider} from 'notistack';
|
import {SnackbarProvider} from 'notistack';
|
||||||
import axios from 'axios';
|
|
||||||
import { userLoggedIn, refreshUserAccountData } from './utilities/accounts';
|
import { userLoggedIn, refreshUserAccountData } from './utilities/accounts';
|
||||||
|
|
||||||
axios.get('config.json').then((resp: any) => {
|
getConfig().then((config: any) => {
|
||||||
document.title = resp.data.branding.name || "Hyperspace";
|
document.title = config.branding.name || "Hyperspace";
|
||||||
}).catch((err: Error) => {
|
}).catch((err: Error) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ import {Config} from '../types/Config';
|
|||||||
import {SaveClientSession} from '../types/SessionData';
|
import {SaveClientSession} from '../types/SessionData';
|
||||||
import { createHyperspaceApp } from '../utilities/login';
|
import { createHyperspaceApp } from '../utilities/login';
|
||||||
import {parseUrl} from 'query-string';
|
import {parseUrl} from 'query-string';
|
||||||
|
import { getConfig } from '../utilities/settings';
|
||||||
|
|
||||||
interface IWelcomeState {
|
interface IWelcomeState {
|
||||||
logoUrl?: string;
|
logoUrl?: string;
|
||||||
@ -39,9 +40,7 @@ class WelcomePage extends Component<any, IWelcomeState> {
|
|||||||
authority: false
|
authority: false
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.get('config.json').then((resp: any) => {
|
getConfig().then((result: any) => {
|
||||||
let result: Config = resp.data;
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
logoUrl: result.branding? result.branding.logo: "logo.png",
|
logoUrl: result.branding? result.branding.logo: "logo.png",
|
||||||
backgroundUrl: result.branding? result.branding.background: "background.png",
|
backgroundUrl: result.branding? result.branding.background: "background.png",
|
||||||
|
@ -4,6 +4,7 @@ export type Config = {
|
|||||||
logo?: string;
|
logo?: string;
|
||||||
background?: string;
|
background?: string;
|
||||||
};
|
};
|
||||||
|
developer?: string;
|
||||||
federated?: string;
|
federated?: string;
|
||||||
registration?: {
|
registration?: {
|
||||||
defaultInstance?: string;
|
defaultInstance?: string;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { defaultTheme, themes } from "../types/HyperspaceTheme";
|
import { defaultTheme, themes } from "../types/HyperspaceTheme";
|
||||||
import { getNotificationRequestPermission } from './notifications';
|
import { getNotificationRequestPermission } from './notifications';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { Config } from "../types/Config";
|
||||||
|
|
||||||
type SettingsTemplate = {
|
type SettingsTemplate = {
|
||||||
[key:string]: any;
|
[key:string]: any;
|
||||||
@ -72,4 +74,13 @@ export function createUserDefaults() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
getNotificationRequestPermission();
|
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