Use new Federation scheme, convert JSON values for bools to boolean

This commit is contained in:
Marquis Kurt 2019-05-08 15:24:36 -04:00
parent 87d5c8af25
commit 9e6e509f30
5 changed files with 23 additions and 14 deletions

View File

@ -6,11 +6,11 @@
"logo": "logo.svg",
"background": "background.png"
},
"developer": "true",
"developer": true,
"federation": {
"universalLogin": "true",
"allowPublicPosts": "true",
"enablePublicTimeline": "true"
"universalLogin": true,
"allowPublicPosts": true,
"enablePublicTimeline": true
},
"registration": {
"defaultInstance": "mastodon.social"

View File

@ -21,6 +21,7 @@ import { Notification } from '../../types/Notification';
import {sendNotificationRequest} from '../../utilities/notifications';
import {withSnackbar} from 'notistack';
import { getConfig, getUserDefaultBool } from '../../utilities/settings';
import { Config } from '../../types/Config';
interface IAppLayoutState {
acctMenuOpen: boolean;
@ -70,12 +71,15 @@ export class AppLayout extends Component<any, IAppLayoutState> {
})
}
getConfig().then((config: any) => {
this.setState({
enableFederation: config.federated === "true",
brandName: config.branding? config.branding.name: "Hyperspace",
developerMode: config.developer === "true"
});
getConfig().then((result: any) => {
if (result !== undefined) {
let config: Config = result;
this.setState({
enableFederation: config.federation.enablePublicTimeline,
brandName: config.branding? config.branding.name: "Hyperspace",
developerMode: config.developer
});
}
})
this.streamNotifications()

View File

@ -65,7 +65,7 @@ class Composer extends Component<any, IComposerState> {
let text = state.acct? `@${state.acct}: `: '';
getConfig().then((config: any) => {
this.setState({
federated: config.federated === "true",
federated: config.federation.allowPublicPosts,
reply: state.reply,
acct: state.acct,
visibility: state.visibility,

View File

@ -43,6 +43,7 @@ import NotificationsIcon from '@material-ui/icons/Notifications';
import BellAlertIcon from 'mdi-material-ui/BellAlert';
import RefreshIcon from '@material-ui/icons/Refresh';
import UndoIcon from '@material-ui/icons/Undo';
import { Config } from '../types/Config';
interface ISettingsState {
darkModeEnabled: boolean;
@ -104,8 +105,12 @@ class SettingsPage extends Component<any, ISettingsState> {
}
getFederatedStatus() {
getConfig().then((config: any) => {
this.setState({ federated: config.federated === "true" });
getConfig().then((result: any) => {
if (result !== undefined) {
let config: Config = result;
console.log(config.federation.allowPublicPosts === false)
this.setState({ federated: config.federation.allowPublicPosts });
}
})
}

View File

@ -6,7 +6,7 @@ export type Config = {
logo?: string;
background?: string;
};
developer?: string;
developer?: boolean;
federation: Federation;
registration?: {
defaultInstance?: string;