Invert if cssAutofit

This commit is contained in:
Cohee
2024-12-21 02:52:05 +02:00
parent d27d750cb2
commit f649e4698b

View File

@@ -916,16 +916,19 @@ export function initRossMods() {
} }
sendTextArea.addEventListener('input', () => { sendTextArea.addEventListener('input', () => {
if (!cssAutofit) {
const hasContent = sendTextArea.value !== '';
const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight;
const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth;
const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2;
const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight));
if (needsDebounce) autoFitSendTextAreaDebounced();
else autoFitSendTextArea();
}
saveUserInputDebounced(); saveUserInputDebounced();
if (cssAutofit) {
return;
}
const hasContent = sendTextArea.value !== '';
const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight;
const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth;
const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2;
const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight));
if (needsDebounce) autoFitSendTextAreaDebounced();
else autoFitSendTextArea();
}); });
restoreUserInput(); restoreUserInput();