mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
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:
@@ -8,6 +8,7 @@ zrequire('unread');
|
|||||||
zrequire('settings_notifications');
|
zrequire('settings_notifications');
|
||||||
const Dict = zrequire('dict').Dict;
|
const Dict = zrequire('dict').Dict;
|
||||||
const FoldDict = zrequire('fold_dict').FoldDict;
|
const FoldDict = zrequire('fold_dict').FoldDict;
|
||||||
|
const IntDict = zrequire('int_dict').IntDict;
|
||||||
|
|
||||||
set_global('page_params', {});
|
set_global('page_params', {});
|
||||||
set_global('blueslip', {});
|
set_global('blueslip', {});
|
||||||
@@ -36,8 +37,8 @@ const zero_counts = {
|
|||||||
private_message_count: 0,
|
private_message_count: 0,
|
||||||
home_unread_messages: 0,
|
home_unread_messages: 0,
|
||||||
mentioned_message_count: 0,
|
mentioned_message_count: 0,
|
||||||
stream_count: new Dict(),
|
stream_count: new IntDict(),
|
||||||
topic_count: new Dict(),
|
topic_count: new IntDict(),
|
||||||
pm_count: new Dict(),
|
pm_count: new Dict(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const Dict = require('./dict').Dict;
|
const Dict = require('./dict').Dict;
|
||||||
const FoldDict = require('./fold_dict').FoldDict;
|
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
|
// See https://zulip.readthedocs.io/en/latest/subsystems/pointer.html for notes on
|
||||||
// how this system is designed.
|
// how this system is designed.
|
||||||
@@ -276,16 +277,12 @@ exports.unread_topic_counter = (function () {
|
|||||||
return new FoldDict();
|
return new FoldDict();
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_dict() {
|
|
||||||
// Use this for stream ids.
|
|
||||||
return new Dict();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.get_counts = function () {
|
self.get_counts = function () {
|
||||||
const res = {};
|
const res = {};
|
||||||
res.stream_unread_messages = 0;
|
res.stream_unread_messages = 0;
|
||||||
res.stream_count = num_dict(); // hash by stream_id -> count
|
res.stream_count = new IntDict(); // hash by stream_id -> count
|
||||||
res.topic_count = num_dict(); // hash of hashes (stream_id, then topic -> count)
|
res.topic_count = new IntDict(); // hash of hashes (stream_id, then topic -> count)
|
||||||
bucketer.each(function (per_stream_bucketer, stream_id) {
|
bucketer.each(function (per_stream_bucketer, stream_id) {
|
||||||
|
|
||||||
// We track unread counts for streams that may be currently
|
// We track unread counts for streams that may be currently
|
||||||
|
|||||||
Reference in New Issue
Block a user