chat fixes

This commit is contained in:
Barış Soner Uşaklı
2023-01-29 19:53:36 -05:00
parent bad0eef089
commit 00a0ffd3f2
4 changed files with 11 additions and 7 deletions

View File

@@ -103,7 +103,7 @@
"nodebb-theme-harmony": "1.0.0-beta.48",
"nodebb-theme-lavender": "7.0.7",
"nodebb-theme-peace": "2.0.17",
"nodebb-theme-persona": "13.0.47",
"nodebb-theme-persona": "13.0.48",
"nodebb-widget-essentials": "7.0.5",
"nodemailer": "6.8.0",
"nprogress": "0.2.0",

View File

@@ -528,7 +528,7 @@ define('forum/chats', [
if (!utils.isMobile()) {
$('.expanded-chat [component="chat/input"]').focus();
}
messages.updateTextAreaHeight();
messages.updateTextAreaHeight($(`[component="chat/messages"][data-roomid="${ajaxify.data.roomId}"]`));
}
$('.chats-list li').removeClass('active');
$('.chats-list li[data-roomid="' + ajaxify.data.roomId + '"]').addClass('active');

View File

@@ -14,11 +14,11 @@ define('forum/chats/messages', [
if (!message.trim().length) {
return;
}
const chatContent = inputEl.parents(`[component="chat/messages"][data-roomid="${roomId}"]`);
inputEl.val('').trigger('input');
inputEl.removeAttr('data-mid');
messages.updateRemainingLength(inputEl.parent());
messages.updateTextAreaHeight();
messages.updateTextAreaHeight(chatContent);
const payload = { roomId, message, mid };
({ roomId, message, mid } = await hooks.fire('filter:chat.send', payload));
@@ -61,14 +61,18 @@ define('forum/chats/messages', [
});
};
messages.updateTextAreaHeight = function () {
messages.updateTextAreaHeight = function (chatContentEl) {
// https://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize
const textarea = $('.expanded-chat [component="chat/input"]');
const textarea = chatContentEl.find('[component="chat/input"]');
const scrollHeight = textarea.prop('scrollHeight');
textarea.css({ height: scrollHeight + 'px', 'overflow-y': 'hidden' });
textarea.on('input', function () {
const isAtBottom = messages.isAtBottom(chatContentEl.find('.chat-content'));
textarea.css({ height: 0 });
textarea.css({ height: textarea.prop('scrollHeight') + 'px' });
if (isAtBottom) {
messages.scrollToBottom(chatContentEl.find('.chat-content'));
}
});
};

View File

@@ -245,7 +245,7 @@ define('chat', [
});
});
scrollStop.apply(chatModal.find('[component="chat/messages"]'));
scrollStop.apply(chatModal.find('[component="chat/messages"] .chat-content'));
chatModal.find('#chat-close-btn').on('click', function () {
module.close(uuid);