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 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,