mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
popovers: Refactor compose_enter_sends popover.
This commit is contained in:
committed by
Tim Abbott
parent
39936dee5d
commit
602be3ed68
@@ -40,7 +40,6 @@ import {parse_html} from "./ui_util";
|
|||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
import {user_settings} from "./user_settings";
|
import {user_settings} from "./user_settings";
|
||||||
|
|
||||||
export let compose_enter_sends_popover_displayed = false;
|
|
||||||
let message_actions_popover_keyboard_toggle = false;
|
let message_actions_popover_keyboard_toggle = false;
|
||||||
|
|
||||||
const popover_instances = {
|
const popover_instances = {
|
||||||
@@ -51,6 +50,7 @@ const popover_instances = {
|
|||||||
message_actions: null,
|
message_actions: null,
|
||||||
stream_settings: null,
|
stream_settings: null,
|
||||||
compose_mobile_button: null,
|
compose_mobile_button: null,
|
||||||
|
compose_enter_sends: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function sidebar_menu_instance_handle_keyboard(instance, key) {
|
export function sidebar_menu_instance_handle_keyboard(instance, key) {
|
||||||
@@ -70,6 +70,10 @@ export function get_starred_messages_popover() {
|
|||||||
return popover_instances.starred_messages;
|
return popover_instances.starred_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function is_compose_enter_sends_popover_displayed() {
|
||||||
|
return popover_instances.compose_enter_sends?.state.isVisible;
|
||||||
|
}
|
||||||
|
|
||||||
function get_popover_items_for_instance(instance) {
|
function get_popover_items_for_instance(instance) {
|
||||||
const $current_elem = $(instance.popper);
|
const $current_elem = $(instance.popper);
|
||||||
const class_name = $current_elem.attr("class");
|
const class_name = $current_elem.attr("class");
|
||||||
@@ -116,7 +120,7 @@ const left_sidebar_tippy_options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function any_active() {
|
export function any_active() {
|
||||||
return compose_enter_sends_popover_displayed || get_visible_instance();
|
return Boolean(get_visible_instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_show_prep(instance) {
|
function on_show_prep(instance) {
|
||||||
@@ -279,9 +283,9 @@ export function initialize() {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
compose_enter_sends_popover_displayed = true;
|
|
||||||
},
|
},
|
||||||
onMount(instance) {
|
onMount(instance) {
|
||||||
|
popover_instances.compose_enter_sends = instance;
|
||||||
common.adjust_mac_kbd_tags(".enter_sends_choices kbd");
|
common.adjust_mac_kbd_tags(".enter_sends_choices kbd");
|
||||||
|
|
||||||
$(instance.popper).one("click", ".enter_sends_choice", (e) => {
|
$(instance.popper).one("click", ".enter_sends_choice", (e) => {
|
||||||
@@ -307,7 +311,7 @@ export function initialize() {
|
|||||||
},
|
},
|
||||||
onHidden(instance) {
|
onHidden(instance) {
|
||||||
instance.destroy();
|
instance.destroy();
|
||||||
compose_enter_sends_popover_displayed = false;
|
popover_instances.compose_enter_sends = undefined;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ export function initialize() {
|
|||||||
content: $t({defaultMessage: "Change send shortcut"}),
|
content: $t({defaultMessage: "Change send shortcut"}),
|
||||||
onShow() {
|
onShow() {
|
||||||
// Don't show tooltip if the popover is displayed.
|
// Don't show tooltip if the popover is displayed.
|
||||||
if (popover_menus.compose_enter_sends_popover_displayed) {
|
if (popover_menus.is_compose_enter_sends_popover_displayed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user