commit fb97f9e1419de81559f0d892066831b3d17d1011
parent e394e8c17a46576dea203b0a906596573f770fdb
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 8 Feb 2022 03:15:32 +0100
Fix translations
Diffstat:
17 files changed, 95 insertions(+), 53 deletions(-)
diff --git a/components/Footer.tsx b/components/Footer.tsx
@@ -6,9 +6,9 @@ export default class Footer extends PureComponent {
render() {
return (
<footer className="w-full lg:min-h-[25rem] min-h-[12.5rem] bg-[#FEFEFE] dark:bg-[#12161D] flex lg:flex-row flex-col justify-center items-center z-0">
- <Link href={`https://github.com/MTRNord/matrix-art`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Github')}</a></Link>
- <Link href={`https://matrix.to/#/#matrix-art:nordgedanken.dev`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Matrix')}</a></Link>
- <Link href={`/profile/${encodeURIComponent("@mtrnord:nordgedanken.dev")}`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Developer')}</a></Link>
+ <Link href={`https://github.com/MTRNord/matrix-art`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Github') ?? 'Github'}</a></Link>
+ <Link href={`https://matrix.to/#/#matrix-art:nordgedanken.dev`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Matrix') ?? 'Matrix'}</a></Link>
+ <Link href={`/profile/${encodeURIComponent("@mtrnord:nordgedanken.dev")}`} passHref><a className="px-16 text-lg text-gray-700 dark:text-gray-400 font-bold">{i18n?.t('Developer') ?? 'Developer'}</a></Link>
</footer>
);
}
diff --git a/components/FrontPageImage.tsx b/components/FrontPageImage.tsx
@@ -58,7 +58,7 @@ export default class FrontPageImage extends PureComponent<Props, State> {
try {
const profile = await this.context.client.getProfile(this.props.event.sender);
this.setState({
- displayname: profile.displayname || this.props.event.sender,
+ displayname: profile.displayname ?? this.props.event.sender,
});
} catch (error) {
console.debug(`Failed to fetch profile for user ${this.props.event.sender}:`, error);
@@ -99,7 +99,7 @@ export default class FrontPageImage extends PureComponent<Props, State> {
const caption_text = event.content['m.caption'].filter(cap => {
const possible_html_caption = (cap as { body: string; mimetype: string; });
const possible_text_caption = (cap as { "m.text": string; });
- return (possible_html_caption.body && possible_html_caption.mimetype === "text/html") || possible_text_caption["m.text"];
+ return (possible_html_caption.body && possible_html_caption.mimetype === "text/html") ?? possible_text_caption["m.text"];
}).map(cap => {
const possible_html_caption = (cap as { body: string; mimetype: string; });
const possible_text_caption = (cap as { "m.text": string; });
@@ -122,7 +122,7 @@ export default class FrontPageImage extends PureComponent<Props, State> {
const caption_text = event.content['m.caption'].filter(cap => {
const possible_html_caption = (cap as { body: string; mimetype: string; });
const possible_text_caption = (cap as { "m.text": string; });
- return (possible_html_caption.body && possible_html_caption.mimetype === "text/html") || possible_text_caption["m.text"];
+ return (possible_html_caption.body && possible_html_caption.mimetype === "text/html") ?? possible_text_caption["m.text"];
}).map(cap => {
const possible_html_caption = (cap as { body: string; mimetype: string; });
const possible_text_caption = (cap as { "m.text": string; });
diff --git a/components/Header.tsx b/components/Header.tsx
@@ -86,20 +86,20 @@ export default class Header extends PureComponent<Props, State> {
if (typeof window !== "undefined" && isGuest) {
return (
<>
- <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/register">{i18n?.t('Join')}</Link></span>
- <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/login">{i18n?.t('Log in')}</Link></span>
+ <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/register">{i18n?.t('Join') ?? 'Join'}</Link></span>
+ <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/login">{i18n?.t('Log in') ?? 'Log in'}</Link></span>
</>
);
} else if (typeof window !== "undefined") {
if (this.state.directory_data.some(thing => thing.mxid == this.context.client.userId)) {
return (
<>
- <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href={"/profile/" + encodeURIComponent(this.context.client.userId!)}>{i18n?.t('Profile')}</Link></span>
- <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout')}</Link></span>
+ <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href={"/profile/" + encodeURIComponent(this.context.client.userId!)}>{i18n?.t('Profile') ?? 'Profile'}</Link></span>
+ <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout') ?? 'Logout'}</Link></span>
</>
);
}
- return <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout')}</Link></span>;
+ return <span className='px-4 h-auto min-w-[1.5rem] flex items-center whitespace-nowrap cursor-pointer text-gray-900 dark:text-gray-200 font-medium brightness-100 hover:brightness-75 duration-200 ease-in-out transition-all'><Link href="/logout/">{i18n?.t('Logout') ?? 'Logout'}</Link></span>;
}
}}
@@ -127,9 +127,9 @@ export default class Header extends PureComponent<Props, State> {
console.log("isGuest3:", isGuest);
if (typeof window !== "undefined" && !isGuest) {
if (this.state.directory_data.some(thing => thing.mxid == this.context.client.userId)) {
- return <Link href="/submit"><a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Submit')}</a></Link>;
+ return <Link href="/submit"><a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Submit') ?? 'Submit'}</a></Link>;
} else {
- return <a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Setup Account')}</a>;
+ return <a className='inline-flex justify-center items-center text-teal-400 hover:text-teal-200 bg-transparent relative h-14 min-w-[9.25rem] z-[2] cursor-pointer font-bold'>{i18n?.t('Setup Account') ?? 'Setup Account'}</a>;
}
}
}}
diff --git a/components/editIcon.tsx b/components/editIcon.tsx
@@ -17,8 +17,8 @@ export class EditIcon extends PureComponent<Props, State> {
super(props);
this.state = {
- className: (props.className || "") + " dark:fill-white fill-black",
- onClick: props.onClick || (() => {/*noop*/ })
+ className: (props.className ?? "") + " dark:fill-white fill-black",
+ onClick: props.onClick ?? (() => {/*noop*/ })
};
}
static propTypes = {
diff --git a/components/submit_page/main.tsx b/components/submit_page/main.tsx
@@ -466,28 +466,28 @@ class MainSubmissionForm extends PureComponent<Props, State> {
<form className="flex flex-col w-full">
<label className="inner-flex flex-col">
<span className="text-xl text-gray-900 dark:text-gray-200 font-bold">{i18n?.t('Image Title')}</span>
- <input required name="title" value={this.state[`${this.state.currentFileIndex}_title`] || ""} type="text" placeholder={i18n?.t("Set an image title")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
+ <input required name="title" value={this.state[`${this.state.currentFileIndex}_title`] ?? ""} type="text" placeholder={i18n?.t("Set an image title")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
</label>
<span className="h-4"></span>
<label className="inner-flex flex-col">
<span className="text-xl text-gray-900 dark:text-gray-200 font-bold">{i18n?.t("Description")}</span>
- <textarea name="description" value={this.state[`${this.state.currentFileIndex}_description`] || ""} placeholder={i18n?.t("Description Text of the current image")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
+ <textarea name="description" value={this.state[`${this.state.currentFileIndex}_description`] ?? ""} placeholder={i18n?.t("Description Text of the current image")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
</label>
<span className="h-4"></span>
<label className="inner-flex flex-col">
<span className="text-xl text-gray-900 dark:text-gray-200 font-bold">{i18n?.t("Image Tags")}</span>
- <input name="tags" type="text" value={this.state[`${this.state.currentFileIndex}_tags`] || ""} placeholder={i18n?.t("Enter tags (Separate with a comma)")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
+ <input name="tags" type="text" value={this.state[`${this.state.currentFileIndex}_tags`] ?? ""} placeholder={i18n?.t("Enter tags (Separate with a comma)")} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)} />
</label>
<span className="h-4"></span>
<label className="inner-flex flex-col">
<span className="text-xl text-gray-900 dark:text-gray-200 font-bold">{i18n?.t("License")}</span>
- <select defaultValue="" required name="license" value={this.state[`${this.state.currentFileIndex}_license`] || ""} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)}>
+ <select defaultValue="" required name="license" value={this.state[`${this.state.currentFileIndex}_license`] ?? ""} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)}>
<option value="" disabled>{i18n?.t("Select an Creative Commons License")}</option>
<option value="cc-by-4.0">Attribution 4.0 International (CC BY 4.0)</option>
<option value="cc-by-sa-4.0">Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</option>
@@ -503,7 +503,7 @@ class MainSubmissionForm extends PureComponent<Props, State> {
<label className="inner-flex flex-col">
<span className="text-xl text-gray-900 dark:text-gray-200 font-bold">{i18n?.t("Mature/NSFW Content?")}</span>
- <select defaultValue="" required name="nsfw" value={this.state[`${this.state.currentFileIndex}_nsfw`] || ""} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)}>
+ <select defaultValue="" required name="nsfw" value={this.state[`${this.state.currentFileIndex}_nsfw`] ?? ""} className="min-w-full placeholder:text-gray-900 text-gray-900 rounded py-1.5 px-2" onChange={this.handleInputChange.bind(this)}>
<option value="" disabled>{i18n?.t("Select Yes or No")}</option>
<option value="no">{i18n?.t("No")}</option>
<option value="yes">{i18n?.t("Yes")}</option>
diff --git a/components/uploadIcon.tsx b/components/uploadIcon.tsx
@@ -17,8 +17,8 @@ export class UploadIcon extends PureComponent<Props, State> {
super(props);
this.state = {
- className: (props.className || "") + " dark:fill-white fill-black",
- onClick: props.onClick || (() => {/*noop*/ })
+ className: (props.className ?? "") + " dark:fill-white fill-black",
+ onClick: props.onClick ?? (() => {/*noop*/ })
};
}
diff --git a/helpers/matrix_client.ts b/helpers/matrix_client.ts
@@ -2,7 +2,7 @@
import { MatrixContents, MatrixEvent } from './event_types';
import Storage from './storage';
-export const constMatrixArtServer = process.env.NEXT_PUBLIC_DEFAULT_SERVER_URL || "https://matrix.art.midnightthoughts.space";
+export const constMatrixArtServer = process.env.NEXT_PUBLIC_DEFAULT_SERVER_URL ?? "https://matrix.art.midnightthoughts.space";
export default class MatrixClient {
private joinedRooms: Map<string, string> = new Map<string, string>(); // room alias -> room ID
@@ -24,7 +24,7 @@ export default class MatrixClient {
}
get profileRoomId(): string | undefined {
- return this.joinedRooms.get(`#${this.userId}`) || this._profileRoomId;
+ return this.joinedRooms.get(`#${this.userId}`) ?? this._profileRoomId;
}
constructor(private storage: Storage) {
@@ -409,7 +409,7 @@ export default class MatrixClient {
if (process.env.NEXT_PUBLIC_ENV === "test") {
return "mxc://blub/blub";
}
- const fileName = (file as File).name || Date.now();
+ const fileName = (file as File).name ?? Date.now();
const mediaUrl = this.serverUrl?.slice(0, -1 * "/client".length);
const res = await fetch(
`${mediaUrl}/media/r0/upload?filename=${encodeURIComponent(
@@ -543,7 +543,7 @@ export default class MatrixClient {
console.error("No access token");
return [];
}
- limit = limit || 100;
+ limit = limit ?? 100;
let seenEvents = 0;
let from;
let msgs: MatrixEvent[] = [];
diff --git a/pages/404.tsx b/pages/404.tsx
@@ -0,0 +1,20 @@
+import { GetStaticProps } from "next";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+import { PureComponent, ReactNode } from "react";
+
+class Custom404 extends PureComponent {
+ render(): ReactNode {
+ return <h1>404 - Page Not Found</h1>;
+ }
+}
+
+export const getStaticProps: GetStaticProps = async ({ locale }) => {
+ return {
+ props: {
+ ...(await serverSideTranslations(locale ?? 'en', ['common']))
+ }
+ };
+
+};
+
+export default Custom404;
+\ No newline at end of file
diff --git a/pages/500.tsx b/pages/500.tsx
@@ -0,0 +1,20 @@
+import { GetStaticProps } from "next";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+import { PureComponent, ReactNode } from "react";
+
+class Custom500 extends PureComponent {
+ render(): ReactNode {
+ return <h1>500 - Server-side error occurred</h1>;
+ }
+}
+
+export const getStaticProps: GetStaticProps = async ({ locale }) => {
+ return {
+ props: {
+ ...(await serverSideTranslations(locale ?? 'en', ['common']))
+ }
+ };
+
+};
+
+export default Custom500;
+\ No newline at end of file
diff --git a/pages/api/posts/feed.rss.ts b/pages/api/posts/feed.rss.ts
@@ -28,11 +28,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const feed = new Feed({
title: "Matrix-Art",
description: "Matrix-Art is a Deviantart style application for posting media based on Matrix.",
- id: "https://" + (req.headers.host || "art.midnightthoughts.space"),
- link: "https://" + (req.headers.host || "art.midnightthoughts.space"),
+ id: "https://" + (req.headers.host ?? "art.midnightthoughts.space"),
+ link: "https://" + (req.headers.host ?? "art.midnightthoughts.space"),
language: "en",
copyright: "",
- feed: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/posts.rss",
+ feed: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/posts.rss",
namespaces: {
"xmlns:creativeCommons": "http://backend.userland.com/creativeCommonsRssModule",
"xmlns:media": "https://search.yahoo.com/mrss/"
@@ -84,13 +84,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
for (let image of imageEvent.content["m.image_gallery"]) {
feed.addItem({
title: image["m.text"],
- id: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/post/" + imageEvent.event_id + "_" + image["m.file"].url,
- link: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
+ id: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/post/" + imageEvent.event_id + "_" + image["m.file"].url,
+ link: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
description: `<img src="${client?.downloadLink(image["m.file"].url)!}"/>`,
author: [
{
name: imageEvent.content.displayname,
- link: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/profile/" + imageEvent.sender
+ link: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/profile/" + imageEvent.sender
}
],
// TODO extract real time
@@ -139,13 +139,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
} else {
feed.addItem({
title: imageEvent.content["m.text"],
- id: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
- link: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
+ id: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
+ link: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/post/" + imageEvent.event_id,
description: `<img src="${client?.downloadLink(imageEvent.content["m.file"].url)!}"/>`,
author: [
{
name: imageEvent.content.displayname,
- link: "https://" + (req.headers.host || "art.midnightthoughts.space") + "/profile/" + imageEvent.sender
+ link: "https://" + (req.headers.host ?? "art.midnightthoughts.space") + "/profile/" + imageEvent.sender
}
],
date: new Date(imageEvent.origin_server_ts),
diff --git a/pages/api/submitSearch.ts b/pages/api/submitSearch.ts
@@ -26,7 +26,7 @@ export type SearchMedia = {
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const client = new MeiliSearch({
- host: process.env.SEARCH_URL || 'http://127.0.0.1:7700', apiKey: process.env.MEILI_MASTER_KEY || 'xxx'
+ host: process.env.SEARCH_URL ?? 'http://127.0.0.1:7700', apiKey: process.env.MEILI_MASTER_KEY ?? 'xxx'
});
// Run cors
diff --git a/pages/index.tsx b/pages/index.tsx
@@ -124,7 +124,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale }) =>
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
);
- console.log(`locale: ${locale || 'en'}`);
+ console.log(`locale: ${locale ?? 'en'}`);
try {
const data = await get_data();
if (!client?.accessToken) {
@@ -136,7 +136,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale }) =>
console.error("Failed to register as guest:", error);
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
image_events: []
}
};
@@ -173,7 +173,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale }) =>
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
image_events: image_events
}
};
diff --git a/pages/login.tsx b/pages/login.tsx
@@ -199,7 +199,7 @@ Login.contextType = ClientContext;
export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
};
diff --git a/pages/logout.tsx b/pages/logout.tsx
@@ -36,7 +36,7 @@ Logout.contextType = ClientContext;
export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
};
diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx
@@ -112,7 +112,7 @@ class Post extends PureComponent<Props, State> {
const profile = await client.getProfile(image_event.sender);
this.setState({
image_event: image_event as MatrixImageEvents,
- displayname: profile.displayname || image_event.sender,
+ displayname: profile.displayname ?? image_event.sender,
});
} catch (error) {
@@ -456,7 +456,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale, quer
console.error("Failed to register as guest:", error);
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
directory_data: JSON.stringify(data),
event_id: event_id,
hasFullyLoaded: false,
@@ -485,19 +485,19 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale, quer
const profile = await client.getProfile(image_event.sender);
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
image_event: image_event as MatrixImageEvents,
event_id: event_id,
hasFullyLoaded: true,
displayname: profile.displayname,
- avatar_url: profile.avatar_url || null // eslint-disable-line unicorn/no-null
+ avatar_url: profile.avatar_url ?? null // eslint-disable-line unicorn/no-null
}
};
} catch (error) {
console.debug(`Failed to fetch profile for user ${image_event.sender}:`, error);
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
image_event: image_event as MatrixImageEvents,
event_id: event_id,
hasFullyLoaded: true,
@@ -509,14 +509,14 @@ export const getServerSideProps: GetServerSideProps = async ({ res, locale, quer
} catch {
return {
notFound: true, props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
}
}
return {
notFound: true, props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
diff --git a/pages/profile/[userid].tsx b/pages/profile/[userid].tsx
@@ -80,7 +80,7 @@ class Profile extends PureComponent<Props, State> {
try {
const profile = await this.context.client.getProfile(this.props.mxid);
this.setState({
- displayname: profile.displayname || this.props.event.sender,
+ displayname: profile.displayname ?? this.props.event.sender,
avatar_url: profile.avatar_url,
});
} catch (error) {
@@ -358,21 +358,21 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
try {
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
mxid: mxid
}
};
} catch {
return {
notFound: true, props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
}
}
return {
notFound: true, props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
diff --git a/pages/submit.tsx b/pages/submit.tsx
@@ -130,7 +130,7 @@ Submit.contextType = ClientContext;
export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
return {
props: {
- ...(await serverSideTranslations(locale || 'en', ['common'])),
+ ...(await serverSideTranslations(locale ?? 'en', ['common'])),
}
};
};