Update Prettier, refactor expressions with nullish coaslescing

This commit is contained in:
Marquis Kurt 2020-04-22 10:13:54 -04:00
parent f960f4a0bc
commit a70ccd013f
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
3 changed files with 25 additions and 53 deletions

6
package-lock.json generated
View File

@ -13719,9 +13719,9 @@
"dev": true "dev": true
}, },
"prettier": { "prettier": {
"version": "1.18.2", "version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true "dev": true
}, },
"pretty-bytes": { "pretty-bytes": {

View File

@ -28,7 +28,7 @@
"megalodon": "^0.6.4", "megalodon": "^0.6.4",
"moment": "^2.24.0", "moment": "^2.24.0",
"notistack": "^0.5.1", "notistack": "^0.5.1",
"prettier": "1.18.2", "prettier": "^1.19.1",
"query-string": "^6.11.1", "query-string": "^6.11.1",
"react": "^16.13.0", "react": "^16.13.0",
"react-dom": "^16.13.0", "react-dom": "^16.13.0",

View File

@ -98,11 +98,9 @@ class AboutPage extends Component<any, IAboutPageState> {
.finally(() => { .finally(() => {
this.setState({ this.setState({
federation: config.federation, federation: config.federation,
developer: config.developer ? config.developer : false, developer: config.developer ?? false,
versionNumber: config.version, versionNumber: config.version,
brandName: config.branding brandName: config.branding.name ?? "Hyperspace",
? config.branding.name
: "Hyperspace",
brandBg: config.branding.background, brandBg: config.branding.background,
license: { license: {
name: config.license.name, name: config.license.name,
@ -115,11 +113,7 @@ class AboutPage extends Component<any, IAboutPageState> {
} }
shouldRenderInstanceContact(): boolean { shouldRenderInstanceContact(): boolean {
if (this.state.instance != null) { return this.state.instance?.version?.match(/Pleroma/) == null ?? false;
return this.state.instance.version.match(/Pleroma/) == null;
} else {
return false;
}
} }
render() { render() {
@ -131,7 +125,7 @@ class AboutPage extends Component<any, IAboutPageState> {
className={classes.instanceHeaderPaper} className={classes.instanceHeaderPaper}
style={{ style={{
backgroundImage: `url("${ backgroundImage: `url("${
this.state.brandBg ? this.state.brandBg : "" this.state.brandBg ?? ""
}")` }")`
}} }}
> >
@ -158,9 +152,7 @@ class AboutPage extends Component<any, IAboutPageState> {
<Typography> <Typography>
Version{" "} Version{" "}
{`${ {`${
this.state this.state.versionNumber ?? "1.1.x"
? this.state.versionNumber
: "1.0.x"
} ${ } ${
this.state && this.state &&
this.state.brandName !== "Hyperspace" this.state.brandName !== "Hyperspace"
@ -177,15 +169,10 @@ class AboutPage extends Component<any, IAboutPageState> {
this.state.hyperspaceAdmin ? this.state.hyperspaceAdmin ?
<LinkableAvatar <LinkableAvatar
to={`/profile/${ to={`/profile/${
this.state.hyperspaceAdmin this.state.hyperspaceAdmin?.id ?? 0
? this.state.hyperspaceAdmin.id
: 0
}`} }`}
src={ src={
this.state.hyperspaceAdmin this.state.hyperspaceAdmin?.avatar_static ?? ""
? this.state.hyperspaceAdmin
.avatar_static
: ""
} }
> >
<PersonIcon /> <PersonIcon />
@ -222,10 +209,7 @@ class AboutPage extends Component<any, IAboutPageState> {
? "public" ? "public"
: "private" : "private"
}&acct=${ }&acct=${
this.state.hyperspaceAdmin this.state.hyperspaceAdmin?.acct ?? ""
? this.state.hyperspaceAdmin
.acct
: ""
}`} }`}
> >
<ChatIcon /> <ChatIcon />
@ -234,9 +218,7 @@ class AboutPage extends Component<any, IAboutPageState> {
<Tooltip title="View profile"> <Tooltip title="View profile">
<LinkableIconButton <LinkableIconButton
to={`/profile/${ to={`/profile/${
this.state.hyperspaceAdmin this.state.hyperspaceAdmin?.id ?? 0
? this.state.hyperspaceAdmin.id
: 0
}`} }`}
> >
<AssignmentIndIcon /> <AssignmentIndIcon />
@ -295,10 +277,7 @@ class AboutPage extends Component<any, IAboutPageState> {
className={classes.instanceHeaderPaper} className={classes.instanceHeaderPaper}
style={{ style={{
backgroundImage: `url("${ backgroundImage: `url("${
this.state.instance && this.state.instance?.thumbnail ?? ""
this.state.instance.thumbnail
? this.state.instance.thumbnail
: ""
}")` }")`
}} }}
> >
@ -313,15 +292,11 @@ class AboutPage extends Component<any, IAboutPageState> {
</IconButton> </IconButton>
<div className={classes.instanceHeaderText}> <div className={classes.instanceHeaderText}>
<Typography variant="h4" component="p"> <Typography variant="h4" component="p">
{this.state.instance {this.state.instance?.uri ?? "Loading..."}
? this.state.instance.uri
: "Loading..."}
</Typography> </Typography>
<Typography> <Typography>
Server version{" "} Server version{" "}
{this.state.instance {this.state.instance?.version ?? "x.x.x"}
? this.state.instance.version
: "x.x.x"}
</Typography> </Typography>
</div> </div>
</div> </div>
@ -370,10 +345,7 @@ class AboutPage extends Component<any, IAboutPageState> {
<Tooltip title="View profile"> <Tooltip title="View profile">
<LinkableIconButton <LinkableIconButton
to={`/profile/${ to={`/profile/${
this.state.instance this.state.instance?.contact_account.id ?? 0
? this.state.instance
.contact_account.id
: 0
}`} }`}
> >
<AssignmentIndIcon /> <AssignmentIndIcon />
@ -452,8 +424,8 @@ class AboutPage extends Component<any, IAboutPageState> {
secondary={ secondary={
this.state.federation && this.state.federation &&
this.state.federation.enablePublicTimeline this.state.federation.enablePublicTimeline
? "This instance is federated." ? "This copy of Hyperspace is federated."
: "This instance is not federated." : "This copy of Hyperspace is not federated."
} }
/> />
</ListItem> </ListItem>
@ -468,8 +440,8 @@ class AboutPage extends Component<any, IAboutPageState> {
secondary={ secondary={
this.state.federation && this.state.federation &&
this.state.federation.universalLogin this.state.federation.universalLogin
? "This instance supports universal login." ? "This copy of Hyperspace supports universal login."
: "This instance does not support universal login." : "This copy of Hyperspace does not support universal login."
} }
/> />
</ListItem> </ListItem>
@ -484,8 +456,8 @@ class AboutPage extends Component<any, IAboutPageState> {
secondary={ secondary={
this.state.federation && this.state.federation &&
this.state.federation.allowPublicPosts this.state.federation.allowPublicPosts
? "This instance allows posting publicly." ? "This copy of Hyperspace allows posting publicly."
: "This instance does not allow posting publicly." : "This copy of Hyperspace does not allow posting publicly."
} }
/> />
</ListItem> </ListItem>
@ -495,11 +467,11 @@ class AboutPage extends Component<any, IAboutPageState> {
<div className={classes.pageLayoutFooter}> <div className={classes.pageLayoutFooter}>
<Typography variant="caption"> <Typography variant="caption">
(C) {new Date().getFullYear()}{" "} (C) {new Date().getFullYear()}{" "}
{this.state ? this.state.brandName : "Hyperspace"}{" "} {this.state.brandName ?? "Hyperspace"}{" "}
developers. All rights reserved. developers. All rights reserved.
</Typography> </Typography>
<Typography variant="caption" paragraph> <Typography variant="caption" paragraph>
{this.state ? this.state.brandName : "Hyperspace"}{" "} {this.state.brandName ?? "Hyperspace"}{" "}
Desktop is made possible by the{" "} Desktop is made possible by the{" "}
<Link <Link
href={"https://material-ui.com"} href={"https://material-ui.com"}