mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
removed io from user.js, figure out why notifications are breaking when websockets.js is required from it
This commit is contained in:
@@ -106,13 +106,13 @@
|
||||
notifList.appendChild(notifFrag);
|
||||
|
||||
if (data.unread.length > 0) {
|
||||
notifIcon.className = 'fa-circle active';
|
||||
notifIcon.className = 'fa fa-circle active';
|
||||
} else {
|
||||
notifIcon.className = 'fa-circle-o';
|
||||
notifIcon.className = 'fa fa-circle-o';
|
||||
}
|
||||
|
||||
socket.emit('api:notifications.mark_all_read', null, function() {
|
||||
notifIcon.className = 'fa-circle-o';
|
||||
notifIcon.className = 'fa fa-circle-o';
|
||||
utils.refreshTitle();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,7 +151,9 @@ define(function() {
|
||||
}
|
||||
|
||||
register.on('click', function(e) {
|
||||
if (validateForm()) e.preventDefault();
|
||||
if (validateForm()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var RDB = require('./redis.js'),
|
||||
var RDB = require('./redis'),
|
||||
async = require('async'),
|
||||
utils = require('../public/src/utils.js'),
|
||||
utils = require('../public/src/utils'),
|
||||
winston = require('winston'),
|
||||
cron = require('cron').CronJob,
|
||||
|
||||
@@ -82,7 +82,12 @@ var RDB = require('./redis.js'),
|
||||
(function(uid) {
|
||||
notifications.remove_by_uniqueId(notif_data.uniqueId, uid, function() {
|
||||
RDB.zadd('uid:' + uid + ':notifications:unread', notif_data.datetime, nid);
|
||||
|
||||
global.io.sockets.in('uid_' + uid).emit('event:new_notification');
|
||||
|
||||
// TODO: moving this require to the top of the file overwrites 'notifications' figure out why -baris
|
||||
//require('./websockets').in('uid_' + uid).emit('event:new_notification');
|
||||
|
||||
if (callback) {
|
||||
callback(true);
|
||||
}
|
||||
|
||||
@@ -178,11 +178,13 @@
|
||||
|
||||
app.post('/register', function(req, res) {
|
||||
user.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
|
||||
|
||||
if (err === null && uid) {
|
||||
req.login({
|
||||
uid: uid
|
||||
}, function() {
|
||||
|
||||
require('./../websockets').emitUserCount();
|
||||
|
||||
if(req.body.referrer)
|
||||
res.redirect(req.body.referrer);
|
||||
else
|
||||
|
||||
@@ -6,7 +6,7 @@ var RDB = require('./redis.js'),
|
||||
posts = require('./posts.js'),
|
||||
threadTools = require('./threadTools.js'),
|
||||
postTools = require('./postTools'),
|
||||
Notifications = require('./notifications'),
|
||||
notifications = require('./notifications'),
|
||||
async = require('async'),
|
||||
feed = require('./feed.js'),
|
||||
favourites = require('./favourites.js'),
|
||||
@@ -677,7 +677,7 @@ var RDB = require('./redis.js'),
|
||||
user.notifications.getUnreadByUniqueId(uid, 'topic:' + tid, function(err, nids) {
|
||||
if (nids.length > 0) {
|
||||
async.each(nids, function(nid, next) {
|
||||
Notifications.mark_read(nid, uid, next);
|
||||
notifications.mark_read(nid, uid, next);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
10
src/user.js
10
src/user.js
@@ -102,15 +102,7 @@ var bcrypt = require('bcrypt'),
|
||||
User.sendConfirmationEmail(email);
|
||||
}
|
||||
|
||||
RDB.incr('usercount', function(err, count) {
|
||||
RDB.handle(err);
|
||||
|
||||
if (typeof io !== 'undefined') {
|
||||
io.sockets.emit('user.count', {
|
||||
count: count
|
||||
});
|
||||
}
|
||||
});
|
||||
RDB.incr('usercount');
|
||||
|
||||
RDB.zadd('users:joindate', timestamp, uid);
|
||||
RDB.zadd('users:postcount', 0, uid);
|
||||
|
||||
@@ -636,7 +636,8 @@ module.exports.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:notifications.mark_all_read', function(data, callback) {
|
||||
notifications.mark_all_read(uid, function(err) {
|
||||
console.log(notifications);
|
||||
require('./notifications').mark_all_read(uid, function(err) {
|
||||
if (!err) callback();
|
||||
});
|
||||
});
|
||||
@@ -1010,4 +1011,17 @@ module.exports.init = function(io) {
|
||||
socket.on('api:admin.theme.set', meta.themes.set);
|
||||
});
|
||||
|
||||
module.exports.emitUserCount = function() {
|
||||
RDB.get('usercount', function(err, count) {
|
||||
io.sockets.emit('user.count', {
|
||||
count: count
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.in = function(room) {
|
||||
return io.sockets.in(room);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user