Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unread: Stop accessing page_param.unread_msgs after init.

Zixuan James Lib9f7edb58a03
diff --git a/static/js/navbar_alerts.js b/static/js/navbar_alerts.js
index 85577921f5d..2f891104605 100644
--- a/static/js/navbar_alerts.js
+++ b/static/js/navbar_alerts.js
@@ -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",
diff --git a/static/js/unread.js b/static/js/unread.js
index 2b43f2b465e..0e2d060dcba 100644
--- a/static/js/unread.js
+++ b/static/js/unread.js
@@ -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;
diff --git a/static/js/unread_ui.js b/static/js/unread_ui.js
index 3cbdeaf50c1..92194e11869 100644
--- a/static/js/unread_ui.js
+++ b/static/js/unread_ui.js
@@ -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.