Fix logic again

I really need to rename these variables to be less confusing
This commit is contained in:
Lim Chee Aun 2023-07-22 20:31:13 +08:00
parent 28ad18bd0b
commit eb13fe8ce0

View file

@ -251,26 +251,35 @@ function Status({
const targetLanguage = getTranslateTargetLanguage(true); const targetLanguage = getTranslateTargetLanguage(true);
const contentTranslationHideLanguages = const contentTranslationHideLanguages =
snapStates.settings.contentTranslationHideLanguages || []; snapStates.settings.contentTranslationHideLanguages || [];
if (!snapStates.settings.contentTranslation) enableTranslate = false; const { contentTranslation, contentTranslationAutoInline } =
snapStates.settings;
if (!contentTranslation) enableTranslate = false;
const inlineTranslate = useMemo(() => { const inlineTranslate = useMemo(() => {
if (
!contentTranslation ||
!contentTranslationAutoInline ||
readOnly ||
(withinContext && !isSizeLarge) ||
previewMode ||
spoilerText ||
sensitive ||
poll ||
card ||
mediaAttachments?.length
) {
return false;
}
const contentLength = htmlContentLength(content); const contentLength = htmlContentLength(content);
return ( return contentLength > 0 && contentLength <= INLINE_TRANSLATE_LIMIT;
!readOnly &&
(!withinContext || isSizeLarge) &&
!previewMode &&
!spoilerText &&
!poll &&
!card &&
!mediaAttachments?.length &&
contentLength > 0 &&
contentLength <= INLINE_TRANSLATE_LIMIT
);
}, [ }, [
contentTranslation,
contentTranslationAutoInline,
readOnly, readOnly,
withinContext, withinContext,
isSizeLarge, isSizeLarge,
previewMode, previewMode,
spoilerText, spoilerText,
sensitive,
poll, poll,
card, card,
mediaAttachments, mediaAttachments,