client: fix null i18n interpolation values

Fixed the occurence that was reported in
<FoundKeyGang/FoundKey#317> along with a similar one.

Fixes <FoundKeyGang/FoundKey#317>

Also changed the i18n code so this should not happen any more in the general case.
This commit is contained in:
Johann150 2023-01-05 20:50:25 +01:00
parent a0c2cf328e
commit 35e9d7f958
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
3 changed files with 3 additions and 3 deletions

View file

@ -33,7 +33,7 @@ class I18n<T extends Record<string, any>> {
// Perform string interpolation.
if (args) {
for (const [k, v] of Object.entries(args)) {
str = str.replace(`{${k}}`, v.toString());
str = str.replace(`{${k}}`, v?.toString());
}
}

View file

@ -127,7 +127,7 @@ definePageMetadata(computed(() => note ? {
avatar: note.user,
path: `/notes/${note.id}`,
share: {
title: i18n.t('noteOf', { user: note.user.name }),
title: i18n.t('noteOf', { user: note.user.name || note.user.username }),
text: note.text,
},
} : null));

View file

@ -183,7 +183,7 @@ export function getNoteMenu(props: {
function share(): void {
navigator.share({
title: i18n.t('noteOf', { user: appearNote.user.name }),
title: i18n.t('noteOf', { user: appearNote.user.name || appearNote.user.username }),
text: appearNote.text,
url: `${url}/notes/${appearNote.id}`,
});