fix: chats, allow multiple dropdowns like in harmony

This commit is contained in:
Barış Soner Uşaklı
2023-02-09 19:30:32 -05:00
parent f11e72410c
commit b72d185211
2 changed files with 10 additions and 9 deletions

View File

@@ -482,7 +482,7 @@ define('forum/chats', [
newMessage = data.self === 0;
}
data.message.self = data.self;
data.message.timestamp = Math.min(Date.now(), data.message.timetamp);
data.message.timestamp = Math.min(Date.now(), data.message.timestamp);
data.message.timestampISO = utils.toISOString(data.message.timestamp);
messages.appendChatMessage($('.expanded-chat .chat-content'), data.message);
} else if (ajaxify.data.template.chats) {

View File

@@ -4,20 +4,21 @@ define('forum/header/chat', ['components', 'hooks'], function (components, hooks
const chat = {};
chat.prepareDOM = function () {
const chatsListEl = components.get('chat/list');
const chatsToggleEl = $('[component="chat/dropdown"]');
if (!chatsToggleEl) {
if (!chatsToggleEl.length) {
return;
}
chatsToggleEl.on('show.bs.dropdown', () => {
requireAndCall('loadChatsDropdown', chatsListEl);
chatsToggleEl.on('show.bs.dropdown', (ev) => {
requireAndCall('loadChatsDropdown', $(ev.target).parent().find('[component="chat/list"]'));
});
if (chatsToggleEl.parents('.dropdown').hasClass('show')) {
requireAndCall('loadChatsDropdown', chatsListEl);
}
chatsToggleEl.each((index, el) => {
const dropdownEl = $(el).parent().find('.dropdown-menu');
if (dropdownEl.hasClass('show')) {
requireAndCall('loadChatsDropdown', dropdownEl.find('[component="chat/list"]'));
}
});
socket.removeListener('event:chats.receive', onChatMessageReceived);
socket.on('event:chats.receive', onChatMessageReceived);