From a70ccd013ff48656d0ce80555f71321c9a2a9ec5 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Wed, 22 Apr 2020 10:13:54 -0400 Subject: [PATCH] Update Prettier, refactor expressions with nullish coaslescing --- package-lock.json | 6 ++-- package.json | 2 +- src/pages/About.tsx | 70 ++++++++++++++------------------------------- 3 files changed, 25 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0b97d9..680c651 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13719,9 +13719,9 @@ "dev": true }, "prettier": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", - "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, "pretty-bytes": { diff --git a/package.json b/package.json index bd55d82..c688383 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "megalodon": "^0.6.4", "moment": "^2.24.0", "notistack": "^0.5.1", - "prettier": "1.18.2", + "prettier": "^1.19.1", "query-string": "^6.11.1", "react": "^16.13.0", "react-dom": "^16.13.0", diff --git a/src/pages/About.tsx b/src/pages/About.tsx index af59f8a..f471a20 100644 --- a/src/pages/About.tsx +++ b/src/pages/About.tsx @@ -98,11 +98,9 @@ class AboutPage extends Component { .finally(() => { this.setState({ federation: config.federation, - developer: config.developer ? config.developer : false, + developer: config.developer ?? false, versionNumber: config.version, - brandName: config.branding - ? config.branding.name - : "Hyperspace", + brandName: config.branding.name ?? "Hyperspace", brandBg: config.branding.background, license: { name: config.license.name, @@ -115,11 +113,7 @@ class AboutPage extends Component { } shouldRenderInstanceContact(): boolean { - if (this.state.instance != null) { - return this.state.instance.version.match(/Pleroma/) == null; - } else { - return false; - } + return this.state.instance?.version?.match(/Pleroma/) == null ?? false; } render() { @@ -131,7 +125,7 @@ class AboutPage extends Component { className={classes.instanceHeaderPaper} style={{ backgroundImage: `url("${ - this.state.brandBg ? this.state.brandBg : "" + this.state.brandBg ?? "" }")` }} > @@ -158,9 +152,7 @@ class AboutPage extends Component { Version{" "} {`${ - this.state - ? this.state.versionNumber - : "1.0.x" + this.state.versionNumber ?? "1.1.x" } ${ this.state && this.state.brandName !== "Hyperspace" @@ -177,15 +169,10 @@ class AboutPage extends Component { this.state.hyperspaceAdmin ? @@ -222,10 +209,7 @@ class AboutPage extends Component { ? "public" : "private" }&acct=${ - this.state.hyperspaceAdmin - ? this.state.hyperspaceAdmin - .acct - : "" + this.state.hyperspaceAdmin?.acct ?? "" }`} > @@ -234,9 +218,7 @@ class AboutPage extends Component { @@ -295,10 +277,7 @@ class AboutPage extends Component { className={classes.instanceHeaderPaper} style={{ 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 {
- {this.state.instance - ? this.state.instance.uri - : "Loading..."} + {this.state.instance?.uri ?? "Loading..."} Server version{" "} - {this.state.instance - ? this.state.instance.version - : "x.x.x"} + {this.state.instance?.version ?? "x.x.x"}
@@ -370,10 +345,7 @@ class AboutPage extends Component { @@ -452,8 +424,8 @@ class AboutPage extends Component { secondary={ this.state.federation && this.state.federation.enablePublicTimeline - ? "This instance is federated." - : "This instance is not federated." + ? "This copy of Hyperspace is federated." + : "This copy of Hyperspace is not federated." } /> @@ -468,8 +440,8 @@ class AboutPage extends Component { secondary={ this.state.federation && this.state.federation.universalLogin - ? "This instance supports universal login." - : "This instance does not support universal login." + ? "This copy of Hyperspace supports universal login." + : "This copy of Hyperspace does not support universal login." } /> @@ -484,8 +456,8 @@ class AboutPage extends Component { secondary={ this.state.federation && this.state.federation.allowPublicPosts - ? "This instance allows posting publicly." - : "This instance does not allow posting publicly." + ? "This copy of Hyperspace allows posting publicly." + : "This copy of Hyperspace does not allow posting publicly." } /> @@ -495,11 +467,11 @@ class AboutPage extends Component {
(C) {new Date().getFullYear()}{" "} - {this.state ? this.state.brandName : "Hyperspace"}{" "} + {this.state.brandName ?? "Hyperspace"}{" "} developers. All rights reserved. - {this.state ? this.state.brandName : "Hyperspace"}{" "} + {this.state.brandName ?? "Hyperspace"}{" "} Desktop is made possible by the{" "}