Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
resize: Fix expensive navbar.resize_app calls leaving recent_topics.
YashRE4233af1c1cd65a
diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex 31190d6a7f6..4936c092589 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -17,7 +17,6 @@ import * as message_view_header from "./message_view_header";import * as muted_topics from "./muted_topics";import * as narrow from "./narrow";import * as narrow_state from "./narrow_state";-import * as navbar_alerts from "./navbar_alerts";import * as navigate from "./navigate";import * as people from "./people";import * as recent_senders from "./recent_senders";@@ -684,9 +683,8 @@ export function hide() {// before it completely re-rerenders.message_view_header.render_title_area();- // Fixes misaligned message_view and hidden- // floating_recipient_bar.- navbar_alerts.resize_app();+ // Fire our custom event+ $("#message_feed_container").trigger("message_feed_shown");// This makes sure user lands on the selected message// and not always at the top of the narrow.diff --git a/static/js/resize.js b/static/js/resize.jsindex 4dcec231527..a75b6edc6a7 100644--- a/static/js/resize.js+++ b/static/js/resize.js@@ -8,6 +8,7 @@ import * as message_viewport from "./message_viewport";import * as navbar_alerts from "./navbar_alerts";import * as navigate from "./navigate";import * as popovers from "./popovers";+import * as recent_topics_util from "./recent_topics_util";import * as ui from "./ui";import {user_settings} from "./user_settings";import * as util from "./util";@@ -284,3 +285,28 @@ export function handler() {navigate.scroll_to_selected();}}++export function initialize() {+ // Hack: If the app is loaded directly to recent topics, then we+ // need to arrange to call navbar_alerts.resize_app when we first+ // visit a message list. This is a workaround for bugs where the+ // floating recipient bar will be invisible (as well as other+ // alignment issues) when they are initially rendered in the+ // background because recent topics is displayed.++ if (recent_topics_util.is_visible()) {+ // We bind the handler for the message_feed_container shown event, such+ // that it will only get executed once.+ //+ // The selector here is based on #gear-menu, to take advantage+ // of the Bootstrap the 'show' event handler on that legacy+ // data-toggle element.+ $('#gear-menu a[data-toggle="tab"][href="#message_feed_container"]').one("show", () => {+ // We use a requestAnimationFrame here to prevent this call from+ // causing a forced reflow.+ window.requestAnimationFrame(() => {+ navbar_alerts.resize_app();+ });+ });+ }+}diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex b15da43cade..3ec04bfdd80 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -658,6 +658,8 @@ export function initialize_everything() {// All overlays must be initialized before hashchange.jshashchange.initialize();+ resize.initialize();+unread_ui.initialize();activity.initialize();emoji_picker.initialize();