refactor: Use sub_store for get/validation.

This reduces the complexity of our dependency graph.

It also makes sub_store.get parallel to message_store.get.
For both you pass in the relevant id to get the
full validated object.
This commit is contained in:
Steve Howell
2021-04-15 15:02:54 +00:00
committed by Tim Abbott
parent d2bbb7d521
commit 173ce9a3fc
26 changed files with 90 additions and 83 deletions

View File

@@ -5,6 +5,7 @@ import {page_params} from "./page_params";
import * as people from "./people";
import * as settings_config from "./settings_config";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
import * as util from "./util";
// The unread module tracks the message IDs and locations of the
@@ -242,7 +243,7 @@ class UnreadTopicCounter {
// unsubscribed. Since users may re-subscribe, we don't
// completely throw away the data. But we do ignore it here,
// so that callers have a view of the **current** world.
const sub = stream_data.get_sub_by_id(stream_id);
const sub = sub_store.get(stream_id);
if (!sub || !stream_data.is_subscribed(sub.name)) {
continue;
}
@@ -297,7 +298,7 @@ class UnreadTopicCounter {
return 0;
}
const sub = stream_data.get_sub_by_id(stream_id);
const sub = sub_store.get(stream_id);
for (const [topic, msgs] of per_stream_bucketer) {
if (sub && !muting.is_topic_muted(stream_id, topic)) {
stream_count += msgs.size;
@@ -329,7 +330,7 @@ class UnreadTopicCounter {
}
const ids = [];
const sub = stream_data.get_sub_by_id(stream_id);
const sub = sub_store.get(stream_id);
for (const [topic, id_set] of per_stream_bucketer) {
if (sub && !muting.is_topic_muted(stream_id, topic)) {
for (const id of id_set) {