mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 17:56:16 +01:00
Merge remote-tracking branch 'origin/master' into dbal
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"403.title": "Access Denied",
|
||||
"403.message": "You seem to have stumbled upon a page that you do not have access to. Perhaps you should <a href='/login'>try logging in</a>?",
|
||||
"404.title": "Not Found",
|
||||
"404.message": "You seem to have stumbled upon a page that does not exist. Return to the <a href='/''>home page</a>.",
|
||||
"404.message": "You seem to have stumbled upon a page that does not exist. Return to the <a href='/'>home page</a>.",
|
||||
"500.title": "Internal error.",
|
||||
"500.message": "Ooops! Looks like something went wrong!",
|
||||
"logout": "Logout",
|
||||
@@ -16,5 +16,6 @@
|
||||
"header.unread": "Unread",
|
||||
"header.users": "Users",
|
||||
"header.search": "Search",
|
||||
"notifications.loading": "Loading Notifications"
|
||||
"notifications.loading": "Loading Notifications",
|
||||
"chats.loading": "Loading Chats"
|
||||
}
|
||||
@@ -47,7 +47,8 @@ var socket,
|
||||
|
||||
socket.on('connect', function (data) {
|
||||
if (reconnecting) {
|
||||
reconnectEl.html('<i class="fa fa-check"></i> Connected!');
|
||||
reconnectEl.tooltip('destroy');
|
||||
reconnectEl.html('<i class="fa fa-check"></i>');
|
||||
reconnecting = false;
|
||||
|
||||
setTimeout(function() {
|
||||
@@ -74,8 +75,12 @@ var socket,
|
||||
if (!reconnectEl) reconnectEl = $('#reconnect');
|
||||
reconnecting = true;
|
||||
|
||||
if (!reconnectEl.hasClass('active')) reconnectEl.html('<i class="fa fa-spinner fa-spin"></i>');
|
||||
reconnectEl.addClass('active');
|
||||
reconnectEl.html('<i class="fa fa-spinner fa-spin"></i> Reconnecting...');
|
||||
|
||||
reconnectEl.tooltip({
|
||||
placement: 'bottom'
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:user.get_online_users', function (users) {
|
||||
|
||||
@@ -175,6 +175,38 @@
|
||||
Tinycon.setBubble(savedCount+1);
|
||||
});
|
||||
|
||||
// Chats Dropdown
|
||||
var chatsToggleEl = $('#chat_dropdown'),
|
||||
chatsListEl = $('#chat-list'),
|
||||
chatDropdownEl = chatsToggleEl.parent();
|
||||
chatsToggleEl.on('click', function() {
|
||||
if (chatDropdownEl.hasClass('open')) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('api:chats.list', function(chats) {
|
||||
var chatsFrag = document.createDocumentFragment(),
|
||||
chatEl = document.createElement('li'),
|
||||
numChats = chats.length,
|
||||
x, userObj;
|
||||
|
||||
if (numChats > 0) {
|
||||
for(x=0;x<numChats;x++) {
|
||||
userObj = chats[x];
|
||||
chatEl.setAttribute('data-uid', userObj.uid);
|
||||
chatEl.innerHTML = '<a href="javascript:app.openChat(\'' + userObj.username + '\', ' + userObj.uid + ');"><img src="' + userObj.picture + '" title="' + userObj.username + '" />' + userObj.username + '</a>';
|
||||
|
||||
chatsFrag.appendChild(chatEl.cloneNode(true));
|
||||
}
|
||||
} else {
|
||||
chatEl.innerHTML = '<a href="#">No Recent Chats</a>';
|
||||
chatsFrag.appendChild(chatEl.cloneNode(true));
|
||||
}
|
||||
|
||||
chatsListEl.empty();
|
||||
chatsListEl.html(chatsFrag);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('chatMessage', function(data) {
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ define(['taskbar'], function(taskbar) {
|
||||
chatModal.show();
|
||||
module.bringModalToTop(chatModal);
|
||||
checkOnlineStatus(chatModal);
|
||||
taskbar.updateActive(uuid);
|
||||
}
|
||||
|
||||
module.minimize = function(uuid) {
|
||||
|
||||
@@ -87,6 +87,11 @@ define(function() {
|
||||
toggleNew: function(uuid, state) {
|
||||
var btnEl = $(taskbar.tasklist.querySelector('[data-uuid="' + uuid + '"]'));
|
||||
btnEl.toggleClass('new', state);
|
||||
},
|
||||
updateActive: function(uuid) {
|
||||
var tasks = $(taskbar.tasklist).find('li');
|
||||
tasks.removeClass('active');
|
||||
tasks.filter('[data-uuid="' + uuid + '"]').addClass('active');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +103,7 @@ define(function() {
|
||||
push: taskbar.push,
|
||||
discard: taskbar.discard,
|
||||
minimize: taskbar.minimize,
|
||||
toggleNew: taskbar.toggleNew
|
||||
toggleNew: taskbar.toggleNew,
|
||||
updateActive: taskbar.updateActive
|
||||
}
|
||||
});
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
<ul id="logged-in-menu" class="nav navbar-nav navbar-right hide">
|
||||
<li>
|
||||
<a href="#" id="reconnect"></a>
|
||||
<a href="#" id="reconnect" title="Connection to {title} has been lost, attempting to reconnect..."><i class="fa fa-check"></i></a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
@@ -89,7 +89,7 @@
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li id="notifications-list" class="notifications dropdown text-center hidden-xs">
|
||||
<li class="notifications dropdown text-center hidden-xs">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="notif_dropdown"></a>
|
||||
<ul id="notif-list" class="dropdown-menu" aria-labelledby="notif_dropdown">
|
||||
<li>
|
||||
@@ -98,6 +98,15 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="chats dropdown text-center hidden-xs">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="chat_dropdown"><i class="fa fa-comment"></i></a>
|
||||
<ul id="chat-list" class="dropdown-menu" aria-labelledby="chat_dropdown">
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-refresh fa-spin"></i> [[global:chats.loading]]</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li id="user_label" class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="user_dropdown">
|
||||
<img src=""/>
|
||||
|
||||
@@ -29,6 +29,8 @@ var db = require('./database'),
|
||||
db.setObject('message:' + mid, message);
|
||||
db.listAppend('messages:' + uids[0] + ':' + uids[1], mid);
|
||||
|
||||
Messaging.updateChatTime(fromuid, touid);
|
||||
Messaging.updateChatTime(touid, fromuid);
|
||||
callback(null, message);
|
||||
});
|
||||
}
|
||||
@@ -78,4 +80,22 @@ var db = require('./database'),
|
||||
});
|
||||
}
|
||||
|
||||
Messaging.updateChatTime = function(uid, toUid, callback) {
|
||||
RDB.zadd('uid:' + uid + ':chats', Date.now(), toUid, function(err) {
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Messaging.getRecentChats = function(uid, callback) {
|
||||
RDB.zrevrange('uid:' + uid + ':chats', 0, 9, function(err, uids) {
|
||||
if (!err) {
|
||||
user.getMultipleUserFields(uids, ['username', 'picture', 'uid'], callback);
|
||||
} else {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}(exports));
|
||||
@@ -395,7 +395,6 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
Topics.pushUnreadCount = function(uids, callback) {
|
||||
if (uids == 0) throw new Error();
|
||||
if (!uids) {
|
||||
clients = websockets.getConnectedClients();
|
||||
uids = Object.keys(clients);
|
||||
|
||||
@@ -22,6 +22,7 @@ var cookie = require('cookie'),
|
||||
notifications = require('./notifications'),
|
||||
threadTools = require('./threadTools'),
|
||||
postTools = require('./postTools'),
|
||||
Messaging = require('./messaging'),
|
||||
meta = require('./meta'),
|
||||
logger = require('./logger'),
|
||||
socketCookieParser = express.cookieParser(nconf.get('secret')),
|
||||
@@ -678,7 +679,7 @@ websockets.init = function(io) {
|
||||
|
||||
socket.on('getChatMessages', function(data, callback) {
|
||||
var touid = data.touid;
|
||||
require('./messaging').getMessages(uid, touid, function(err, messages) {
|
||||
Messaging.getMessages(uid, touid, function(err, messages) {
|
||||
if (err)
|
||||
return callback(null);
|
||||
|
||||
@@ -707,7 +708,7 @@ websockets.init = function(io) {
|
||||
});
|
||||
}
|
||||
|
||||
require('./messaging').addMessage(uid, touid, msg, function(err, message) {
|
||||
Messaging.addMessage(uid, touid, msg, function(err, message) {
|
||||
var numSockets = 0;
|
||||
|
||||
if (userSockets[touid]) {
|
||||
@@ -740,6 +741,16 @@ websockets.init = function(io) {
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:chats.list', function(callback) {
|
||||
Messaging.getRecentChats(uid, function(err, uids) {
|
||||
if (err) {
|
||||
winston.warn('[(socket) api:chats.list] Problem retrieving chats: ' + err.message);
|
||||
}
|
||||
|
||||
callback(uids || []);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('api:config.get', function(data) {
|
||||
meta.configs.list(function(err, config) {
|
||||
if (!err) socket.emit('api:config.get', config);
|
||||
|
||||
Reference in New Issue
Block a user