mirror of https://github.com/zulip/zulip.git
unread: Stop accessing page_param.unread_msgs after init.
This adds a get_unread_message_count helper that returns the size of unread_messages and replaces the usage of page_param.unread_msgs.count elsewhere in the codebase. Fixes #23334. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
6c88ca91b1
commit
b9f7edb58a
|
@ -14,6 +14,7 @@ import * as compose_ui from "./compose_ui";
|
|||
import {localstorage} from "./localstorage";
|
||||
import * as notifications from "./notifications";
|
||||
import {page_params} from "./page_params";
|
||||
import * as unread from "./unread";
|
||||
import * as unread_ops from "./unread_ops";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
import * as util from "./util";
|
||||
|
@ -172,7 +173,7 @@ export function initialize() {
|
|||
rendered_alert_content_html: render_desktop_notifications_alert_content(),
|
||||
});
|
||||
} else if (unread_ui.should_display_bankruptcy_banner()) {
|
||||
const unread_msgs_count = page_params.unread_msgs.count;
|
||||
const unread_msgs_count = unread.get_unread_message_count();
|
||||
open({
|
||||
data_process: "bankruptcy",
|
||||
custom_class: "bankruptcy",
|
||||
|
|
|
@ -517,6 +517,10 @@ export function get_unread_messages(messages) {
|
|||
return messages.filter((message) => unread_messages.has(message.id));
|
||||
}
|
||||
|
||||
export function get_unread_message_count() {
|
||||
return unread_messages.size;
|
||||
}
|
||||
|
||||
export function update_unread_topics(msg, event) {
|
||||
const new_topic = util.get_edit_event_topic(event);
|
||||
const {new_stream_id} = event;
|
||||
|
|
|
@ -100,7 +100,7 @@ export function should_display_bankruptcy_banner() {
|
|||
|
||||
const now = Date.now() / 1000;
|
||||
if (
|
||||
page_params.unread_msgs.count > 500 &&
|
||||
unread.get_unread_message_count() > 500 &&
|
||||
now - page_params.furthest_read_time > 60 * 60 * 24 * 2
|
||||
) {
|
||||
// 2 days.
|
||||
|
|
Loading…
Reference in New Issue