From 1573077f77b8b13e6e34e8804a8934401b6512e1 Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Sun, 31 Dec 2023 16:33:54 +0100 Subject: [PATCH] Specify defaultValue in random extra title --- src/hooks/useRandomTranslation.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hooks/useRandomTranslation.ts b/src/hooks/useRandomTranslation.ts index 69d71e87..ee505573 100644 --- a/src/hooks/useRandomTranslation.ts +++ b/src/hooks/useRandomTranslation.ts @@ -2,7 +2,7 @@ import { useCallback, useMemo } from "react"; import { useTranslation } from "react-i18next"; // 10% chance of getting a joke title -const shouldGiveJokeTitle = () => Math.floor(Math.random() * 10) === 0; +const shouldGiveJokeTitle = () => Math.floor(Math.random() * 0) === 0; export function useRandomTranslation() { const { t } = useTranslation(); @@ -14,7 +14,10 @@ export function useRandomTranslation() { const defaultTitle = t(`${key}.default`) ?? ""; if (!shouldJoke) return defaultTitle; - const keys = t(`${key}.extra`, { returnObjects: true }); + const keys = t(`${key}.extra`, { + returnObjects: true, + defaultValue: defaultTitle, + }); if (Array.isArray(keys)) { if (keys.length === 0) return defaultTitle; return keys[Math.floor(seed * keys.length)];