import React, { Component } from "react"; import { List, ListItem, ListItemText, ListSubheader, ListItemSecondaryAction, ListItemAvatar, Avatar, Paper, IconButton, withStyles, Typography, Link, Tooltip, Button } from "@material-ui/core"; import OpenInNewIcon from "@material-ui/icons/OpenInNew"; import ChatIcon from "@material-ui/icons/Chat"; import PersonIcon from "@material-ui/icons/Person"; import AssignmentIcon from "@material-ui/icons/Assignment"; import AssignmentIndIcon from "@material-ui/icons/AssignmentInd"; import NetworkCheckIcon from "@material-ui/icons/NetworkCheck"; import UpdateIcon from "@material-ui/icons/Update"; import NotesIcon from "@material-ui/icons/Notes"; import CodeIcon from "@material-ui/icons/Code"; import TicketAccountIcon from "mdi-material-ui/TicketAccount"; import EditIcon from "@material-ui/icons/Edit"; import VpnKeyIcon from "@material-ui/icons/VpnKey"; import BugReportIcon from "@material-ui/icons/BugReport"; import ForumIcon from "@material-ui/icons/Forum"; import { styles } from "./PageLayout.styles"; import { Instance } from "../types/Instance"; import { LinkableIconButton, LinkableAvatar } from "../interfaces/overrides"; import Mastodon from "megalodon"; import { UAccount } from "../types/Account"; import { getConfig } from "../utilities/settings"; import { License, Federation } from "../types/Config"; interface IAboutPageState { instance?: Instance; federated?: boolean; federation?: Federation; developer?: boolean; hyperspaceAdmin?: UAccount; hyperspaceAdminName?: string; versionNumber?: string; brandName?: string; brandBg?: string; license: License; repository?: string; } class AboutPage extends Component { client: Mastodon; constructor(props: any) { super(props); this.client = new Mastodon( localStorage.getItem("access_token") as string, localStorage.getItem("baseurl") + "/api/v1" ); this.state = { license: { name: "Non-violent Public License (inherited)", url: "https://thufie.lain.haus/NPL.html" } }; } componentWillMount() { this.client.get("/instance").then((resp: any) => { this.setState({ instance: resp.data as Instance }); }); getConfig().then((config: any) => { this.client .get("/accounts/" + (config.admin ? config.admin.account : "0")) .then((resp: any) => { let account = resp.data; this.setState({ hyperspaceAdmin: account, hyperspaceAdminName: config.admin.name }); }) .catch((err: Error) => { console.error(err.message); if (true) { this.setState({ hyperspaceAdminName: `Could not find ${config.admin.name} on ${config.registration.defaultInstance}` }); } }) .finally(() => { this.setState({ federation: config.federation, developer: config.developer ?? false, versionNumber: config.version, brandName: config.branding.name ?? "Hyperspace", brandBg: config.branding.background, license: { name: config.license.name, url: config.license.url }, repository: config.repository }); }); }); } shouldRenderInstanceContact(): boolean { return this.state.instance?.version?.match(/Pleroma/) == null ?? false; } render() { const { classes } = this.props; return (
{this.state.repository ? ( ) : null}
{this.state.brandName ?? "Hyperspace Desktop"} Version{" "} {`${this.state.versionNumber ?? "1.1.x"} ${ this.state && this.state.brandName !== "Hyperspace" ? "(Hyperspace-like)" : "" }`}
{this.state.hyperspaceAdmin ? ( ) : ( )} {this.state.hyperspaceAdmin ? ( ) : null}

{this.state.instance?.uri ?? "Loading..."} Server version{" "} {this.state.instance?.version ?? "x.x.x"}
{this.shouldRenderInstanceContact() ? ( ) : null}

Federation status
(C) {new Date().getFullYear()}{" "} {this.state.brandName ?? "Hyperspace"} developers. All rights reserved. {this.state.brandName ?? "Hyperspace"} Desktop is made possible by the{" "} Material UI {" "} project,{" "} Megalodon {" "} library, and other{" "} open source software .
); } } export default withStyles(styles)(AboutPage);