Move config setting to state in finally

This commit is contained in:
Marquis Kurt 2020-04-22 09:58:50 -04:00
parent 95b950ab70
commit f960f4a0bc
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
2 changed files with 31 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "hyperspace", "name": "hyperspace",
"version": "1.1.0", "version": "1.1.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -85,6 +85,18 @@ class AboutPage extends Component<any, IAboutPageState> {
this.setState({ this.setState({
hyperspaceAdmin: account, hyperspaceAdmin: account,
hyperspaceAdminName: config.admin.name, 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, federation: config.federation,
developer: config.developer ? config.developer : false, developer: config.developer ? config.developer : false,
versionNumber: config.version, versionNumber: config.version,
@ -98,9 +110,6 @@ class AboutPage extends Component<any, IAboutPageState> {
}, },
repository: config.repository repository: config.repository
}); });
})
.catch((err: Error) => {
console.error(err.message);
}); });
}); });
} }
@ -164,7 +173,9 @@ class AboutPage extends Component<any, IAboutPageState> {
<List className={classes.pageListConstraints}> <List className={classes.pageListConstraints}>
<ListItem> <ListItem>
<ListItemAvatar> <ListItemAvatar>
<LinkableAvatar {
this.state.hyperspaceAdmin ?
<LinkableAvatar
to={`/profile/${ to={`/profile/${
this.state.hyperspaceAdmin this.state.hyperspaceAdmin
? this.state.hyperspaceAdmin.id ? this.state.hyperspaceAdmin.id
@ -179,6 +190,13 @@ class AboutPage extends Component<any, IAboutPageState> {
> >
<PersonIcon /> <PersonIcon />
</LinkableAvatar> </LinkableAvatar>
: <ListItemAvatar>
<Avatar>
<PersonIcon />
</Avatar>
</ListItemAvatar>
}
</ListItemAvatar> </ListItemAvatar>
<ListItemText <ListItemText
primary="App provider" primary="App provider"
@ -189,10 +207,14 @@ class AboutPage extends Component<any, IAboutPageState> {
this.state.hyperspaceAdmin this.state.hyperspaceAdmin
.display_name || .display_name ||
"@" + this.state.hyperspaceAdmin.acct "@" + this.state.hyperspaceAdmin.acct
: "No provider set in config" :
this.state.hyperspaceAdminName
?? "No provider set in config"
} }
/> />
<ListItemSecondaryAction> {
this.state.hyperspaceAdmin?
<ListItemSecondaryAction>
<Tooltip title="Send a post or message"> <Tooltip title="Send a post or message">
<LinkableIconButton <LinkableIconButton
to={`/compose?visibility=${ to={`/compose?visibility=${
@ -221,6 +243,8 @@ class AboutPage extends Component<any, IAboutPageState> {
</LinkableIconButton> </LinkableIconButton>
</Tooltip> </Tooltip>
</ListItemSecondaryAction> </ListItemSecondaryAction>
: null
}
</ListItem> </ListItem>
<ListItem> <ListItem>
<ListItemAvatar> <ListItemAvatar>