mirror of https://github.com/zulip/zulip.git
popovers: Refactor topic_menu visible check and hide logic.
This commit refactors the topic_menu visible check and hide logic, since we have already migrated the popover from stream_popover.js. This last bit of code related to topic_menu is also migrated to popover_menus.js, and the code is refactored to use the new logic, which is more common for the popover_menus.js system. To hide the popover, one possible solution could be to use the hideAll method from TippyJS. However, this could lead to unintentional behavior for all the popovers. To prevent this, the hide method is used for the topic_menu only.
This commit is contained in:
parent
dbd945eb96
commit
af3e62b2ae
|
@ -7,11 +7,11 @@ import * as feedback_widget from "./feedback_widget";
|
|||
import {$t} from "./i18n";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as overlays from "./overlays";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as recent_topics_ui from "./recent_topics_ui";
|
||||
import * as settings_muted_topics from "./settings_muted_topics";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_list from "./stream_list";
|
||||
import * as stream_popover from "./stream_popover";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
import * as user_topics from "./user_topics";
|
||||
|
||||
|
@ -39,7 +39,7 @@ export function rerender_for_muted_topic(old_muted_topics) {
|
|||
export function handle_topic_updates(user_topic) {
|
||||
const old_muted_topics = user_topics.get_muted_topics();
|
||||
user_topics.set_user_topic(user_topic);
|
||||
stream_popover.hide_topic_popover();
|
||||
popover_menus.get_topic_menu_popover()?.hide();
|
||||
unread_ui.update_unread_counts();
|
||||
rerender_for_muted_topic(old_muted_topics);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ export function sidebar_menu_instance_handle_keyboard(instance, key) {
|
|||
export function get_visible_instance() {
|
||||
return Object.values(popover_instances).find(Boolean);
|
||||
}
|
||||
export function get_topic_menu_popover() {
|
||||
return popover_instances.topics_menu;
|
||||
}
|
||||
|
||||
export function get_compose_control_buttons_popover() {
|
||||
return popover_instances.compose_control_buttons;
|
||||
|
|
|
@ -1115,7 +1115,6 @@ export function any_active() {
|
|||
popover_menus.any_active() ||
|
||||
user_sidebar_popped() ||
|
||||
stream_popover.stream_popped() ||
|
||||
stream_popover.topic_popped() ||
|
||||
message_info_popped() ||
|
||||
user_info_popped() ||
|
||||
emoji_picker.reactions_popped() ||
|
||||
|
@ -1135,7 +1134,6 @@ export function hide_all_except_sidebars(opts) {
|
|||
emoji_picker.hide_emoji_popover();
|
||||
giphy.hide_giphy_popover();
|
||||
stream_popover.hide_stream_popover();
|
||||
stream_popover.hide_topic_popover();
|
||||
hide_all_user_info_popovers();
|
||||
hide_playground_links_popover();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as message_store from "./message_store";
|
||||
import {page_params} from "./page_params";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as stream_popover from "./stream_popover";
|
||||
import * as top_left_corner from "./top_left_corner";
|
||||
import {user_settings} from "./user_settings";
|
||||
|
||||
|
@ -81,7 +80,7 @@ export function rerender_ui() {
|
|||
count = 0;
|
||||
}
|
||||
|
||||
stream_popover.hide_topic_popover();
|
||||
popover_menus.get_topic_menu_popover()?.hide();
|
||||
popover_menus.get_starred_messages_popover()?.hide();
|
||||
top_left_corner.update_starred_count(count);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import * as unread_ops from "./unread_ops";
|
|||
// We handle stream popovers and topic popovers in this
|
||||
// module. Both are popped up from the left sidebar.
|
||||
let current_stream_sidebar_elem;
|
||||
let current_topic_sidebar_elem;
|
||||
let stream_widget;
|
||||
let $stream_header_colorblock;
|
||||
|
||||
|
@ -73,10 +72,6 @@ export function stream_popped() {
|
|||
return current_stream_sidebar_elem !== undefined;
|
||||
}
|
||||
|
||||
export function topic_popped() {
|
||||
return current_topic_sidebar_elem !== undefined;
|
||||
}
|
||||
|
||||
export function hide_stream_popover() {
|
||||
if (stream_popped()) {
|
||||
$(current_stream_sidebar_elem).popover("destroy");
|
||||
|
@ -85,14 +80,6 @@ export function hide_stream_popover() {
|
|||
}
|
||||
}
|
||||
|
||||
export function hide_topic_popover() {
|
||||
if (topic_popped()) {
|
||||
$(current_topic_sidebar_elem).popover("destroy");
|
||||
hide_left_sidebar_menu_icon();
|
||||
current_topic_sidebar_elem = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function show_streamlist_sidebar() {
|
||||
$(".app-main .column-left").addClass("expanded");
|
||||
resize.resize_stream_filters_container();
|
||||
|
|
|
@ -7,7 +7,7 @@ import render_topic_list_item from "../templates/topic_list_item.hbs";
|
|||
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as narrow from "./narrow";
|
||||
import * as stream_popover from "./stream_popover";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as stream_topic_history from "./stream_topic_history";
|
||||
import * as stream_topic_history_util from "./stream_topic_history_util";
|
||||
import * as sub_store from "./sub_store";
|
||||
|
@ -35,7 +35,7 @@ export function update() {
|
|||
}
|
||||
|
||||
export function clear() {
|
||||
stream_popover.hide_topic_popover();
|
||||
popover_menus.get_topic_menu_popover()?.hide();
|
||||
|
||||
for (const widget of active_widgets.values()) {
|
||||
widget.remove();
|
||||
|
|
|
@ -84,7 +84,6 @@ mock_esm("../src/recent_topics_util", {
|
|||
|
||||
const stream_popover = mock_esm("../src/stream_popover", {
|
||||
stream_popped: () => false,
|
||||
topic_popped: () => false,
|
||||
});
|
||||
|
||||
message_lists.current = {
|
||||
|
|
|
@ -10,10 +10,6 @@ const {page_params, user_settings} = require("./lib/zpage_params");
|
|||
const top_left_corner = mock_esm("../src/top_left_corner", {
|
||||
update_starred_count() {},
|
||||
});
|
||||
const stream_popover = mock_esm("../src/stream_popover", {
|
||||
hide_topic_popover() {},
|
||||
});
|
||||
|
||||
const message_store = zrequire("message_store");
|
||||
const starred_messages = zrequire("starred_messages");
|
||||
|
||||
|
@ -100,7 +96,6 @@ run_test("rerender_ui", () => {
|
|||
user_settings.starred_message_counts = true;
|
||||
with_overrides(({override}) => {
|
||||
const stub = make_stub();
|
||||
override(stream_popover, "hide_topic_popover", () => {});
|
||||
override(top_left_corner, "update_starred_count", stub.f);
|
||||
starred_messages.rerender_ui();
|
||||
assert.equal(stub.num_calls, 1);
|
||||
|
@ -111,7 +106,6 @@ run_test("rerender_ui", () => {
|
|||
user_settings.starred_message_counts = false;
|
||||
with_overrides(({override}) => {
|
||||
const stub = make_stub();
|
||||
override(stream_popover, "hide_topic_popover", () => {});
|
||||
override(top_left_corner, "update_starred_count", stub.f);
|
||||
starred_messages.rerender_ui();
|
||||
assert.equal(stub.num_calls, 1);
|
||||
|
|
Loading…
Reference in New Issue