mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 22:00:34 +01:00
closes #4585, closes https://github.com/NodeBB/nodebb-theme-persona/issues/299
This commit is contained in:
@@ -189,12 +189,12 @@ app.cacheBuster = null;
|
||||
}
|
||||
}
|
||||
|
||||
app.createUserTooltips = function(els) {
|
||||
app.createUserTooltips = function(els, placement) {
|
||||
els = els || $('body');
|
||||
els.find('.avatar,img[title].teaser-pic,img[title].user-img,div.user-icon,span.user-icon').each(function() {
|
||||
if (!utils.isTouchDevice()) {
|
||||
$(this).tooltip({
|
||||
placement: 'top',
|
||||
placement: placement || $(this).attr('title-placement') || 'top',
|
||||
title: $(this).attr('title')
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,13 +113,12 @@ define('chat', [
|
||||
return room.teaser;
|
||||
});
|
||||
|
||||
chatsListEl.empty();
|
||||
|
||||
templates.parse('partials/chat_dropdown', {
|
||||
rooms: rooms
|
||||
}, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
chatsListEl.html(translated);
|
||||
chatsListEl.empty().html(translated);
|
||||
app.createUserTooltips(chatsListEl, 'right');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -242,6 +242,9 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
roomData: function(next) {
|
||||
Messaging.getRoomsData(roomIds, next);
|
||||
},
|
||||
unread: function(next) {
|
||||
db.isSortedSetMembers('uid:' + uid + ':chat:rooms:unread', roomIds, next);
|
||||
},
|
||||
@@ -254,7 +257,7 @@ var async = require('async'),
|
||||
uids = uids.filter(function(value) {
|
||||
return value && parseInt(value, 10) !== parseInt(uid, 10);
|
||||
});
|
||||
user.getUsersFields(uids, ['uid', 'username', 'picture', 'status', 'lastonline'] , next);
|
||||
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'lastonline'] , next);
|
||||
});
|
||||
}, next);
|
||||
},
|
||||
@@ -267,29 +270,28 @@ var async = require('async'),
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var rooms = results.users.map(function(users, index) {
|
||||
var data = {
|
||||
users: users,
|
||||
unread: results.unread[index],
|
||||
roomId: roomIds[index],
|
||||
teaser: results.teasers[index]
|
||||
};
|
||||
data.users.forEach(function(userData) {
|
||||
|
||||
results.roomData.forEach(function(room, index) {
|
||||
room.users = results.users[index];
|
||||
room.unread = results.unread[index];
|
||||
room.teaser = results.teasers[index];
|
||||
|
||||
room.users.forEach(function(userData) {
|
||||
if (userData && parseInt(userData.uid, 10)) {
|
||||
userData.status = user.getStatus(userData);
|
||||
}
|
||||
});
|
||||
data.users = data.users.filter(function(user) {
|
||||
room.users = room.users.filter(function(user) {
|
||||
return user && parseInt(user.uid, 10);
|
||||
});
|
||||
data.lastUser = data.users[0];
|
||||
data.usernames = data.users.map(function(user) {
|
||||
room.lastUser = room.users[0];
|
||||
|
||||
room.usernames = room.users.map(function(user) {
|
||||
return user.username;
|
||||
}).join(', ');
|
||||
return data;
|
||||
});
|
||||
|
||||
callback(null, {rooms: rooms, nextStart: stop + 1});
|
||||
callback(null, {rooms: results.roomData, nextStart: stop + 1});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -21,6 +21,24 @@ module.exports = function(Messaging) {
|
||||
});
|
||||
};
|
||||
|
||||
Messaging.getRoomsData = function(roomIds, callback) {
|
||||
var keys = roomIds.map(function(roomId) {
|
||||
return 'chat:room:' + roomId;
|
||||
});
|
||||
db.getObjects(keys, function(err, roomData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
roomData.forEach(function(data) {
|
||||
if (data) {
|
||||
data.roomName = data.roomName || '[[modules:chat.roomname, ' + data.roomId + ']]';
|
||||
data.roomName = validator.escape(String(data.roomName));
|
||||
}
|
||||
});
|
||||
callback(null, roomData);
|
||||
});
|
||||
};
|
||||
|
||||
Messaging.newRoom = function(uid, toUids, callback) {
|
||||
var roomId;
|
||||
var now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user