fix: prevent crash when detectedLanguage is null
Some checks failed
Build Renderer / build (push) Has been cancelled
Release / build (ubuntu-latest) (push) Has been cancelled
Release / build (windows-2022) (push) Has been cancelled

This commit is contained in:
Zamitto
2025-10-31 13:57:15 -03:00
parent ff8a61ff7a
commit d167628ed4
2 changed files with 4 additions and 3 deletions

View File

@@ -81,7 +81,8 @@ export function ReviewItem({
const needsTranslation =
!isOwnReview && isDifferentLanguage && review.translations[i18n.language];
const getLanguageName = (languageCode: string) => {
const getLanguageName = (languageCode: string | null) => {
if (!languageCode) return "";
try {
const displayNames = new Intl.DisplayNames([i18n.language], {
type: "language",
@@ -182,7 +183,7 @@ export function ReviewItem({
{showOriginal
? t("hide_original")
: t("show_original_translated_from", {
language: getLanguageName(review.detectedLanguage!),
language: getLanguageName(review.detectedLanguage),
})}
</button>
{showOriginal && (

View File

@@ -252,7 +252,7 @@ export interface GameReview {
translations: {
[key: string]: string;
};
detectedLanguage: string;
detectedLanguage: string | null;
}
export interface TrendingGame extends ShopAssets {