From eb13fe8ce0920f1ac8a32a065d7cddaba05a5639 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 22 Jul 2023 20:31:13 +0800 Subject: [PATCH] Fix logic again I really need to rename these variables to be less confusing --- src/components/status.jsx | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index da3a88dc..3459fd31 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -251,26 +251,35 @@ function Status({ const targetLanguage = getTranslateTargetLanguage(true); const contentTranslationHideLanguages = snapStates.settings.contentTranslationHideLanguages || []; - if (!snapStates.settings.contentTranslation) enableTranslate = false; + const { contentTranslation, contentTranslationAutoInline } = + snapStates.settings; + if (!contentTranslation) enableTranslate = false; const inlineTranslate = useMemo(() => { + if ( + !contentTranslation || + !contentTranslationAutoInline || + readOnly || + (withinContext && !isSizeLarge) || + previewMode || + spoilerText || + sensitive || + poll || + card || + mediaAttachments?.length + ) { + return false; + } const contentLength = htmlContentLength(content); - return ( - !readOnly && - (!withinContext || isSizeLarge) && - !previewMode && - !spoilerText && - !poll && - !card && - !mediaAttachments?.length && - contentLength > 0 && - contentLength <= INLINE_TRANSLATE_LIMIT - ); + return contentLength > 0 && contentLength <= INLINE_TRANSLATE_LIMIT; }, [ + contentTranslation, + contentTranslationAutoInline, readOnly, withinContext, isSizeLarge, previewMode, spoilerText, + sensitive, poll, card, mediaAttachments,