fixed the redis error when going to unread/recent if nextStart is missing

v1.18.x
Baris Soner Usakli 11 years ago
parent f4d23fe5df
commit bae76ebd70

@ -47,6 +47,7 @@ define(['forum/recent'], function(recent) {
if(!$('#topics-container').length) {
return;
}
loadingMoreTopics = true;
socket.emit('topics.loadMoreUnreadTopics', {
after: $('#topics-container').attr('data-nextstart')

@ -287,6 +287,9 @@ var path = require('path'),
app.get('/unread', function (req, res, next) {
var uid = (req.user) ? req.user.uid : 0;
if(!req.user) {
return res.json(403, 'not-allowed');
}
topics.getUnreadTopics(uid, 0, 19, function (err, data) {
if(err) {
return next(err);
@ -298,6 +301,9 @@ var path = require('path'),
app.get('/unread/total', function (req, res, next) {
var uid = (req.user) ? req.user.uid : 0;
if(!req.user) {
return res.json(403, 'not-allowed');
}
topics.getTotalUnread(uid, function (err, data) {
if(err) {
return next(err);

@ -445,7 +445,8 @@ var async = require('async'),
function getTopics(set, uid, tids, callback) {
var returnTopics = {
'topics': []
topics: [],
nextStart: 0
};
if (!tids || !tids.length) {
@ -571,18 +572,14 @@ var async = require('async'),
};
Topics.getUnreadTopics = function(uid, start, stop, callback) {
var unreadTopics = {
'show_markallread_button': 'show',
'no_topics_message': 'hidden',
'topics': []
no_topics_message: '',
show_markallread_button: 'hidden',
nextStart : 0,
topics: []
};
function noUnreadTopics() {
unreadTopics.no_topics_message = '';
unreadTopics.show_markallread_button = 'hidden';
callback(null, unreadTopics);
}
function sendUnreadTopics(topicIds) {
Topics.getTopicsByTids(topicIds, 0, uid, function(err, topicData) {
@ -597,13 +594,8 @@ var async = require('async'),
unreadTopics.topics = topicData;
unreadTopics.nextStart = parseInt(rank, 10) + 1;
if (!topicData || topicData.length === 0) {
unreadTopics.no_topics_message = '';
}
if (uid === 0 || topicData.length === 0) {
unreadTopics.show_markallread_button = 'hidden';
}
unreadTopics.no_topics_message = (!topicData || topicData.length === 0) ? '' : 'hidden';
unreadTopics.show_markallread_button = topicData.length === 0 ? 'hidden' : '';
callback(null, unreadTopics);
});
@ -618,7 +610,7 @@ var async = require('async'),
if (unreadTids.length) {
sendUnreadTopics(unreadTids);
} else {
noUnreadTopics();
callback(null, unreadTopics);
}
});
};

Loading…
Cancel
Save