mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
added badge to header for unread topics count
This commit is contained in:
@@ -42,7 +42,7 @@ button, a {
|
|||||||
vertical-align: 17%;
|
vertical-align: 17%;
|
||||||
}
|
}
|
||||||
.nav .badge {
|
.nav .badge {
|
||||||
vertical-align: 10%;
|
vertical-align: 2%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#alert_window {
|
#alert_window {
|
||||||
|
|||||||
@@ -56,6 +56,10 @@
|
|||||||
$('#topics-container').empty();
|
$('#topics-container').empty();
|
||||||
$('#category-no-topics').removeClass('hidden');
|
$('#category-no-topics').removeClass('hidden');
|
||||||
app.alertSuccess('All topics marked as read!');
|
app.alertSuccess('All topics marked as read!');
|
||||||
|
$('#numUnreadBadge')
|
||||||
|
.removeClass('badge-important')
|
||||||
|
.addClass('badge-inverse')
|
||||||
|
.html('0');
|
||||||
} else {
|
} else {
|
||||||
app.alertError('There was an error marking topics read!');
|
app.alertError('There was an error marking topics read!');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,22 @@
|
|||||||
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
||||||
if (numNotifications > 0) document.querySelector('.notifications a i').className = 'icon-circle active';
|
if (numNotifications > 0) document.querySelector('.notifications a i').className = 'icon-circle active';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery.getJSON(RELATIVE_PATH + '/api/unread/total', function(data) {
|
||||||
|
var badge = jQuery('#numUnreadBadge');
|
||||||
|
badge.html(data.count > 20 ? '20+' : data.count);
|
||||||
|
|
||||||
|
if (data.count > 0) {
|
||||||
|
badge
|
||||||
|
.removeClass('badge-inverse')
|
||||||
|
.addClass('badge-important')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
badge
|
||||||
|
.removeClass('badge-important')
|
||||||
|
.addClass('badge-inverse')
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<a href="/recent">Recent</a>
|
<a href="/recent">Recent</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/unread">Unread</a>
|
<a href="/unread"><span id="numUnreadBadge" class="badge badge-inverse">0</span> Unread</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/users">Users</a>
|
<a href="/users">Users</a>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button id="mark-allread-btn" class="btn {show_markallread_button}">Mark All Read</button>
|
<button id="mark-allread-btn" class="btn {show_markallread_button}">Mark All As Read</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="category row">
|
<div class="category row">
|
||||||
|
|||||||
@@ -128,11 +128,16 @@ marked.setOptions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
Topics.getTotalUnread = function(uid, callback) {
|
Topics.getTotalUnread = function(uid, callback) {
|
||||||
RDB.zcount('topics:recent', '-inf', '+inf', function(err, count) {
|
RDB.zrevrange('topics:recent', 0, 21, function (err, tids) {
|
||||||
if (err) count = 0;
|
Topics.hasReadTopics(tids, uid, function(read) {
|
||||||
console.log(count);
|
var unreadTids = tids.filter(function(tid, index, self) {
|
||||||
|
return read[index] === 0;
|
||||||
|
});
|
||||||
|
|
||||||
callback(count);
|
callback({
|
||||||
|
count: unreadTids.length
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user