mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #7424
This commit is contained in:
@@ -55,28 +55,7 @@ define('chat', [
|
||||
|
||||
newMessage = data.self === 0;
|
||||
if (module.modalExists(data.roomId)) {
|
||||
require(['forum/chats/messages'], function (ChatsMessages) {
|
||||
var modal = module.getModal(data.roomId);
|
||||
|
||||
ChatsMessages.appendChatMessage(modal.find('.chat-content'), data.message);
|
||||
|
||||
if (modal.is(':visible')) {
|
||||
taskbar.updateActive(modal.attr('data-uuid'));
|
||||
ChatsMessages.scrollToBottom(modal.find('.chat-content'));
|
||||
} else if (!ajaxify.data.template.chats) {
|
||||
module.toggleNew(modal.attr('data-uuid'), true, true);
|
||||
}
|
||||
|
||||
if (!isSelf && (!modal.is(':visible') || !app.isFocused)) {
|
||||
updateTitleAndPlaySound(data.message.mid, username);
|
||||
taskbar.push('chat', modal.attr('data-uuid'), {
|
||||
title: '[[modules:chat.chatting_with]] ' + (data.roomName || username),
|
||||
touid: data.message.fromUser.uid,
|
||||
roomId: data.roomId,
|
||||
isSelf: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
addMessageToModal(data);
|
||||
} else if (!ajaxify.data.template.chats) {
|
||||
socket.emit('modules.chats.loadRoom', {
|
||||
roomId: data.roomId,
|
||||
@@ -91,15 +70,44 @@ define('chat', [
|
||||
roomData.silent = true;
|
||||
roomData.uid = app.user.uid;
|
||||
roomData.isSelf = isSelf;
|
||||
module.createModal(roomData, function () {
|
||||
module.createModal(roomData, function (modal) {
|
||||
if (!isSelf) {
|
||||
updateTitleAndPlaySound(data.message.mid, username);
|
||||
}
|
||||
if (!modal) {
|
||||
addMessageToModal(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function addMessageToModal(data) {
|
||||
var modal = module.getModal(data.roomId);
|
||||
var username = data.message.fromUser.username;
|
||||
var isSelf = data.self === 1;
|
||||
require(['forum/chats/messages'], function (ChatsMessages) {
|
||||
ChatsMessages.appendChatMessage(modal.find('.chat-content'), data.message);
|
||||
|
||||
if (modal.is(':visible')) {
|
||||
taskbar.updateActive(modal.attr('data-uuid'));
|
||||
ChatsMessages.scrollToBottom(modal.find('.chat-content'));
|
||||
} else if (!ajaxify.data.template.chats) {
|
||||
module.toggleNew(modal.attr('data-uuid'), true, true);
|
||||
}
|
||||
|
||||
if (!isSelf && (!modal.is(':visible') || !app.isFocused)) {
|
||||
updateTitleAndPlaySound(data.message.mid, username);
|
||||
taskbar.push('chat', modal.attr('data-uuid'), {
|
||||
title: '[[modules:chat.chatting_with]] ' + (data.roomName || username),
|
||||
touid: data.message.fromUser.uid,
|
||||
roomId: data.roomId,
|
||||
isSelf: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateTitleAndPlaySound(mid, username) {
|
||||
app.alternatingTitle('[[modules:chat.user_has_messaged_you, ' + username + ']]');
|
||||
require(['sounds'], function (sounds) {
|
||||
@@ -128,8 +136,12 @@ define('chat', [
|
||||
};
|
||||
|
||||
module.createModal = function (data, callback) {
|
||||
callback = callback || function () {};
|
||||
require(['scrollStop', 'forum/chats', 'forum/chats/messages'], function (scrollStop, Chats, ChatsMessages) {
|
||||
app.parseAndTranslate('chat', data, function (chatModal) {
|
||||
if (module.modalExists(data.roomId)) {
|
||||
return callback(null);
|
||||
}
|
||||
var uuid = utils.generateUUID();
|
||||
var dragged = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user