Display a total count of the number of PMs you have pending.

This is accomplished by continuning to have per-conversation PM counts
but then summing them up into a global count.

We may split this off into per-conversation counts in the future.

(imported from commit 311e3b74715c3a01c0b75837e397a386ab65505c)
This commit is contained in:
Luke Faraone 2013-02-14 14:13:28 -05:00
parent 148e47e74a
commit 32a406a5cf
2 changed files with 9 additions and 3 deletions

View File

@ -116,8 +116,8 @@ var people_list = [
<ul class="filters">
<div id="global_filters">
{# Special-case this link so we don't actually go to page top. #}
<li id="filthome" class="active-filter"><a href="#" onclick="ui.change_tab_to('#home');narrow.deactivate();return false" >Home</a></li>
<li id="filtpers"><a href="#narrow/is/private-message">All private messages</a></li>
<li data-name="home" class="active-filter"><a href="#" onclick="ui.change_tab_to('#home');narrow.deactivate();return false" >Home <span class="count">(<span class="value"></span>)</span></a></li>
<li data-name="private" ><a href="#narrow/is/private-message">All private messages <span class="count">(<span class="value"></span>)</span></a></li>
</div>
<hr id="stream_filters_sep">
<div id="stream_filters" class="scrolling_list"></div>

View File

@ -183,7 +183,7 @@ function message_range(start, end) {
var unread_filters = {'stream': {}, 'private': {}};
function process_unread_counts(messages, decrement) {
var existing, hashkey;
var existing, hashkey, pm_count;
$.each(messages, function (index, message) {
if (message.id <= furthest_read && decrement !== true) {
return;
@ -210,6 +210,12 @@ function process_unread_counts(messages, decrement) {
$.each(unread_filters.stream, function(index, obj) {
ui.set_count("stream", index, Object.keys(obj).length);
});
pm_count = 0;
$.each(unread_filters["private"], function(index, obj) {
pm_count += Object.keys(obj).length;
});
ui.set_count("global", "private", pm_count);
}
function update_selected_message(message, opts) {