Fix: correctly handle the case where the user has no languages configured

zio/stable
Paul Frazee 2023-06-30 12:21:30 -05:00
parent 948b324cd8
commit 93689ad73d
2 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,9 @@ export const PostThreadItem = observer(function PostThreadItem({
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
const translatorUrl = getTranslatorLink(primaryLanguage, record?.text || '')
const needsTranslation = useMemo(
() => !isPostInLanguage(item.post, store.preferences.contentLanguages),
() =>
store.preferences.contentLanguages.length > 0 &&
!isPostInLanguage(item.post, store.preferences.contentLanguages),
[item.post, store.preferences.contentLanguages],
)

View File

@ -66,7 +66,9 @@ export const FeedItem = observer(function ({
const primaryLanguage = store.preferences.contentLanguages[0] || 'en'
const translatorUrl = getTranslatorLink(primaryLanguage, record?.text || '')
const needsTranslation = useMemo(
() => !isPostInLanguage(item.post, store.preferences.contentLanguages),
() =>
store.preferences.contentLanguages.length > 0 &&
!isPostInLanguage(item.post, store.preferences.contentLanguages),
[item.post, store.preferences.contentLanguages],
)