psychobunny 11 years ago
parent 91293350b5
commit 004758f5bd

@ -24,7 +24,7 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat)
.attr('data-content', count > 20 ? '20+' : count); .attr('data-content', count > 20 ? '20+' : count);
} }
function prepareUnreadButton() { function initUnreadTopics() {
var unreadTopics = {}; var unreadTopics = {};
function onNewPost(data) { function onNewPost(data) {
@ -33,6 +33,7 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat)
if (parseInt(post.uid, 10) !== parseInt(app.uid, 10) && !unreadTopics[post.topic.tid]) { if (parseInt(post.uid, 10) !== parseInt(app.uid, 10) && !unreadTopics[post.topic.tid]) {
increaseUnreadCount(); increaseUnreadCount();
markTopicsUnread(post.topic.tid);
unreadTopics[post.topic.tid] = true; unreadTopics[post.topic.tid] = true;
} }
} }
@ -43,6 +44,10 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat)
updateUnreadTopicCount(null, count); updateUnreadTopicCount(null, count);
} }
function markTopicsUnread(tid) {
$('[data-tid="' + tid + '"]').addClass('unread');
}
$(window).on('action:ajaxify.end', function(ev, data) { $(window).on('action:ajaxify.end', function(ev, data) {
var tid = data.url.match(/^topic\/(\d+)/); var tid = data.url.match(/^topic\/(\d+)/);
@ -60,5 +65,5 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat)
socket.on('event:unread.updateChatCount', updateUnreadChatCount); socket.on('event:unread.updateChatCount', updateUnreadChatCount);
socket.emit('user.getUnreadChatCount', updateUnreadChatCount); socket.emit('user.getUnreadChatCount', updateUnreadChatCount);
prepareUnreadButton(); initUnreadTopics();
}); });

Loading…
Cancel
Save