mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-07 15:51:46 +02:00
added API call for total unread topics; moved unread notification parsing to client side
also fixed a bug where the new notification icon glow would disappear on page refresh even if there were existing notifications.
This commit is contained in:
@@ -79,9 +79,7 @@ var ajaxify = {};
|
||||
|
||||
}, url, template);
|
||||
|
||||
socket.emit('api:meta.buildTitle', url, function(title) {
|
||||
document.title = title;
|
||||
});
|
||||
utils.refreshTitle(url);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -126,12 +126,16 @@
|
||||
return tags;
|
||||
},
|
||||
|
||||
refreshTitle: function() {
|
||||
var a = document.createElement('a');
|
||||
refreshTitle: function(url) {
|
||||
if (!url) {
|
||||
var a = document.createElement('a');
|
||||
a.href = document.location;
|
||||
url = a.pathname.slice(1);
|
||||
}
|
||||
|
||||
a.href = document.location;
|
||||
socket.emit('api:meta.buildTitle', a.pathname.slice(1), function(title) {
|
||||
document.title = title;
|
||||
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
|
||||
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
||||
if (numNotifications > 0) document.querySelector('.notifications a i').className = 'icon-circle active';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,9 @@ var utils = require('./../public/src/utils.js'),
|
||||
var title;
|
||||
|
||||
if (err) title = global.config.title || 'NodeBB';
|
||||
else title = (values.notifCount > 0 ? '(' + values.notifCount + ') ' : '') + (values.title ? values.title + ' | ' : '') + (global.config.title || 'NodeBB');
|
||||
else title = (values.title ? values.title + ' | ' : '') + (global.config.title || 'NodeBB');
|
||||
|
||||
callback(null, title);
|
||||
callback(null, title, values.notifCount);
|
||||
});
|
||||
},
|
||||
parseFragment: function(urlFragment, callback) {
|
||||
|
||||
@@ -137,6 +137,13 @@ var user = require('./../user.js'),
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/unread/total', function(req, res) {
|
||||
var uid = (req.user) ? req.user.uid : 0;
|
||||
topics.getTotalUnread(uid, function(data) {
|
||||
res.json(data);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/confirm/:id', function(req, res) {
|
||||
user.email.confirm(req.params.id, function(data) {
|
||||
if (data.status === 'ok') {
|
||||
|
||||
@@ -127,6 +127,15 @@ marked.setOptions({
|
||||
});
|
||||
}
|
||||
|
||||
Topics.getTotalUnread = function(uid, callback) {
|
||||
RDB.zcount('topics:recent', '-inf', '+inf', function(err, count) {
|
||||
if (err) count = 0;
|
||||
console.log(count);
|
||||
|
||||
callback(count);
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getUnreadTopics = function(uid, start, stop, callback) {
|
||||
|
||||
var unreadTopics = {
|
||||
|
||||
@@ -739,8 +739,8 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
});
|
||||
|
||||
socket.on('api:meta.buildTitle', function(text, callback) {
|
||||
meta.title.build(text, uid, function(err, title) {
|
||||
callback(title);
|
||||
meta.title.build(text, uid, function(err, title, numNotifications) {
|
||||
callback(title, numNotifications);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user