streams: Use IntDict for stream/topic unread counts.

Note that we haven't fully swept this for Dict,
since some dicts are keyed by strings.  For
example PM counts can have a huddle like
"101,102,103" as a key.
This commit is contained in:
Steve Howell
2019-12-30 13:42:00 +00:00
committed by Tim Abbott
parent 579bad4829
commit 9ba1829243
2 changed files with 6 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ zrequire('unread');
zrequire('settings_notifications');
const Dict = zrequire('dict').Dict;
const FoldDict = zrequire('fold_dict').FoldDict;
const IntDict = zrequire('int_dict').IntDict;
set_global('page_params', {});
set_global('blueslip', {});
@@ -36,8 +37,8 @@ const zero_counts = {
private_message_count: 0,
home_unread_messages: 0,
mentioned_message_count: 0,
stream_count: new Dict(),
topic_count: new Dict(),
stream_count: new IntDict(),
topic_count: new IntDict(),
pm_count: new Dict(),
};

View File

@@ -1,5 +1,6 @@
const Dict = require('./dict').Dict;
const FoldDict = require('./fold_dict').FoldDict;
const IntDict = require('./int_dict').IntDict;
// See https://zulip.readthedocs.io/en/latest/subsystems/pointer.html for notes on
// how this system is designed.
@@ -276,16 +277,12 @@ exports.unread_topic_counter = (function () {
return new FoldDict();
}
function num_dict() {
// Use this for stream ids.
return new Dict();
}
self.get_counts = function () {
const res = {};
res.stream_unread_messages = 0;
res.stream_count = num_dict(); // hash by stream_id -> count
res.topic_count = num_dict(); // hash of hashes (stream_id, then topic -> count)
res.stream_count = new IntDict(); // hash by stream_id -> count
res.topic_count = new IntDict(); // hash of hashes (stream_id, then topic -> count)
bucketer.each(function (per_stream_bucketer, stream_id) {
// We track unread counts for streams that may be currently