mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
mark read after infinite scroll
dont mark read if already read
This commit is contained in:
@@ -149,7 +149,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
var postcount = $('.user_postcount_' + data.posts[i].uid);
|
var postcount = $('.user_postcount_' + data.posts[i].uid);
|
||||||
postcount.html(parseInt(postcount.html(), 10) + 1);
|
postcount.html(parseInt(postcount.html(), 10) + 1);
|
||||||
}
|
}
|
||||||
socket.emit('topics.markAsRead', [tid]);
|
|
||||||
createNewPosts(data);
|
createNewPosts(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,6 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateTopicTitle() {
|
function updateTopicTitle() {
|
||||||
if($(window).scrollTop() > 50) {
|
if($(window).scrollTop() > 50) {
|
||||||
$('.header-topic-title').find('span').text(ajaxify.variables.get('topic_name')).show();
|
$('.header-topic-title').find('span').text(ajaxify.variables.get('topic_name')).show();
|
||||||
@@ -442,6 +441,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
});
|
});
|
||||||
hidePostToolsForDeletedPosts();
|
hidePostToolsForDeletedPosts();
|
||||||
} else {
|
} else {
|
||||||
|
socket.emit('topics.markAsRead', [tid]);
|
||||||
navigator.update();
|
navigator.update();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,24 +180,45 @@ module.exports = function(Topics) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
markRead: function(next) {
|
topicScores: function(next) {
|
||||||
db.sortedSetAdd('uid:' + uid + ':tids_read', scores, tids, next);
|
db.sortedSetScores('topics:recent', tids, next);
|
||||||
},
|
},
|
||||||
topicData: function(next) {
|
userScores: function(next) {
|
||||||
Topics.getTopicsFields(tids, ['cid'], next);
|
db.sortedSetScores('uid:' + uid + ':tids_read', tids, next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cids = results.topicData.map(function(topic) {
|
tids = tids.filter(function(tid, index) {
|
||||||
return topic && topic.cid;
|
return !results.userScores[index] || results.userScores[index] < results.topicScores[index];
|
||||||
}).filter(function(topic, index, array) {
|
|
||||||
return topic && array.indexOf(topic) === index;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
categories.markAsRead(cids, uid, callback);
|
if (!tids.length) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
async.parallel({
|
||||||
|
markRead: function(next) {
|
||||||
|
db.sortedSetAdd('uid:' + uid + ':tids_read', scores, tids, next);
|
||||||
|
},
|
||||||
|
topicData: function(next) {
|
||||||
|
Topics.getTopicsFields(tids, ['cid'], next);
|
||||||
|
}
|
||||||
|
}, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
var cids = results.topicData.map(function(topic) {
|
||||||
|
return topic && topic.cid;
|
||||||
|
}).filter(function(topic, index, array) {
|
||||||
|
return topic && array.indexOf(topic) === index;
|
||||||
|
});
|
||||||
|
|
||||||
|
categories.markAsRead(cids, uid, callback);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user