mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
more fixes
This commit is contained in:
@@ -69,7 +69,6 @@ define('notifications', ['sounds'], function(sound) {
|
||||
notifIcon.attr('data-content', count > 20 ? '20+' : count);
|
||||
|
||||
Tinycon.setBubble(count);
|
||||
localStorage.setItem('notifications:count', count);
|
||||
};
|
||||
|
||||
socket.emit('notifications.getCount', function(err, count) {
|
||||
@@ -80,8 +79,7 @@ define('notifications', ['sounds'], function(sound) {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:new_notification', function() {
|
||||
|
||||
socket.on('event:new_notification', function(notifData, notifCount) {
|
||||
app.alert({
|
||||
alert_id: 'new_notif',
|
||||
title: '[[notifications:new_notification]]',
|
||||
@@ -95,8 +93,7 @@ define('notifications', ['sounds'], function(sound) {
|
||||
ajaxify.refresh();
|
||||
}
|
||||
|
||||
var savedCount = parseInt(localStorage.getItem('notifications:count'), 10) || 0;
|
||||
updateNotifCount(savedCount + 1);
|
||||
updateNotifCount(notifCount);
|
||||
|
||||
sound.play('notification');
|
||||
});
|
||||
|
||||
@@ -142,8 +142,11 @@ var async = require('async'),
|
||||
return next(err);
|
||||
}
|
||||
|
||||
// Client-side
|
||||
websockets.in('uid_' + uid).emit('event:new_notification', notif_data);
|
||||
User.notifications.getUnreadCount(uid, function(err, count) {
|
||||
if (!err) {
|
||||
websockets.in('uid_' + uid).emit('event:new_notification', notif_data, count);
|
||||
}
|
||||
});
|
||||
|
||||
// Plugins
|
||||
notif_data.uid = uid;
|
||||
|
||||
@@ -71,7 +71,7 @@ module.exports = function(app, middleware, controllers) {
|
||||
bodyShort: '[[notifications:user_posted_to, ' + username + ', ' + topicTitle + ']]',
|
||||
bodyLong: 'asdasd khajsdhakhdakj hdkash dakhdakjdhakjs',
|
||||
path: nconf.get('relative_path') + '/topic/' + topicSlug + '/' + postIndex,
|
||||
uniqueId: 'topic:' + tid,
|
||||
uniqueId: 'topic:' + tid + ':uid:' + fromUid,
|
||||
tid: tid,
|
||||
from: fromUid
|
||||
}, function(err, nid) {
|
||||
|
||||
@@ -90,19 +90,19 @@ function favouriteCommand(command, eventName, socket, data, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
function sendNotificationToPostOwner(data, uid, notification) {
|
||||
if(data && data.pid && uid) {
|
||||
function sendNotificationToPostOwner(data, fromuid, notification) {
|
||||
if(data && data.pid && fromuid) {
|
||||
posts.getPostFields(data.pid, ['tid', 'uid'], function(err, postData) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uid === parseInt(postData.uid, 10)) {
|
||||
if (fromuid === parseInt(postData.uid, 10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
username: async.apply(user.getUserField, uid, 'username'),
|
||||
username: async.apply(user.getUserField, fromuid, 'username'),
|
||||
slug: async.apply(topics.getTopicField, postData.tid, 'slug'),
|
||||
index: async.apply(posts.getPidIndex, data.pid),
|
||||
postContent: function(next) {
|
||||
@@ -122,8 +122,8 @@ function sendNotificationToPostOwner(data, uid, notification) {
|
||||
bodyShort: '[[' + notification + ', ' + results.username + ']]',
|
||||
bodyLong: results.postContent,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.index,
|
||||
uniqueId: 'post:' + data.pid,
|
||||
from: uid
|
||||
uniqueId: 'post:' + data.pid + ':uid:' + fromuid,
|
||||
from: fromuid
|
||||
}, function(err, nid) {
|
||||
if (!err) {
|
||||
notifications.push(nid, [postData.uid]);
|
||||
|
||||
@@ -45,7 +45,8 @@ module.exports = function(Topics) {
|
||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
||||
bodyLong: results.postContent,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid,
|
||||
uniqueId: 'topic:' + tid + ':uid:' + exceptUid,
|
||||
tid: tid,
|
||||
from: exceptUid
|
||||
}, next);
|
||||
});
|
||||
|
||||
@@ -39,11 +39,13 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
var nidsToUniqueIds = {};
|
||||
Object.keys(uniqueIdToNids).forEach(function(uniqueId) {
|
||||
var nids = [];
|
||||
uniqueIds.forEach(function(uniqueId) {
|
||||
nidsToUniqueIds[uniqueIdToNids[uniqueId]] = uniqueId;
|
||||
nids.push(uniqueIdToNids[uniqueId]);
|
||||
});
|
||||
|
||||
async.map(Object.keys(nidsToUniqueIds), function(nid, next) {
|
||||
async.map(nids, function(nid, next) {
|
||||
notifications.get(nid, function(err, notif_data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -261,7 +263,7 @@ var async = require('async'),
|
||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topic.title + ']]',
|
||||
bodyLong: results.postContent,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.topic.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid,
|
||||
uniqueId: 'topic:' + tid + ':uid:' + uid,
|
||||
from: uid
|
||||
}, function(err, nid) {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user