mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 21:03:16 +02:00
closes #2297
This commit is contained in:
@@ -96,5 +96,7 @@
|
||||
"updated.title": "Forum Updated",
|
||||
"updated.message": "This forum has just been updated to the latest version. Click here to refresh the page.",
|
||||
|
||||
"privacy": "Privacy"
|
||||
"privacy": "Privacy",
|
||||
|
||||
"delete_all": "Delete All"
|
||||
}
|
||||
|
||||
@@ -3,13 +3,24 @@ define('forum/notifications', function() {
|
||||
|
||||
Notifications.init = function() {
|
||||
var listEl = $('.notifications-list');
|
||||
|
||||
$('span.timeago').timeago();
|
||||
|
||||
// Allow the user to click anywhere in the LI
|
||||
listEl.on('click', 'li', function(e) {
|
||||
this.querySelector('a').click();
|
||||
});
|
||||
|
||||
$('span.timeago').timeago();
|
||||
|
||||
$('.notifications .delete').on('click', function() {
|
||||
socket.emit('notifications.deleteAll', function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
$('.notifications .delete').addClass('hidden');
|
||||
$('.notifications .alert-info').removeClass('hidden');
|
||||
listEl.empty();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return Notifications;
|
||||
|
||||
@@ -12,4 +12,12 @@ SocketNotifs.getCount = function(socket, data, callback) {
|
||||
user.notifications.getUnreadCount(socket.uid, callback);
|
||||
};
|
||||
|
||||
SocketNotifs.deleteAll = function(socket, data, callback) {
|
||||
if (!socket.uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.notifications.deleteAll(socket.uid, callback);
|
||||
};
|
||||
|
||||
module.exports = SocketNotifs;
|
||||
|
||||
@@ -20,6 +20,9 @@ var async = require('async'),
|
||||
(function(UserNotifications) {
|
||||
|
||||
UserNotifications.get = function(uid, callback) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback(null , {read: [], unread: []});
|
||||
}
|
||||
getNotifications(uid, 10, function(err, notifications) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -230,6 +233,20 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
UserNotifications.deleteAll = function(uid, callback) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback();
|
||||
}
|
||||
async.parallel([
|
||||
function(next) {
|
||||
db.delete('uid:' + uid + ':notifications:unread', next);
|
||||
},
|
||||
function(next) {
|
||||
db.delete('uid:' + uid + ':notifications:read', next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
UserNotifications.sendTopicNotificationToFollowers = function(uid, topicData, postData) {
|
||||
db.getSetMembers('followers:' + uid, function(err, followers) {
|
||||
if (err || !Array.isArray(followers) || !followers.length) {
|
||||
|
||||
Reference in New Issue
Block a user