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.

modals: Rename is_modal_open to is_open.

Aman Agrawald54a917104c1
diff --git a/web/src/hotkey.js b/web/src/hotkey.js
index cd030cc452d..ed6e7d5141b 100644
--- a/web/src/hotkey.js
+++ b/web/src/hotkey.js
@@ -280,7 +280,7 @@ export function process_escape_key(e) {
return true;
}
- if (modals.is_modal_open()) {
+ if (modals.is_open()) {
modals.close_active_modal();
return true;
}
@@ -486,7 +486,7 @@ export function process_enter_key(e) {
// All custom logic for overlays/modals is above; if we're in a
// modal at this point, let the browser handle the event.
- if (modals.is_modal_open()) {
+ if (modals.is_open()) {
return false;
}
@@ -695,7 +695,7 @@ export function process_hotkey(e, hotkey) {
}
// `list_util` will process the event in send later modal.
- if (modals.is_modal_open() && modals.active_modal() !== "#send_later_modal") {
+ if (modals.is_open() && modals.active_modal() !== "#send_later_modal") {
return false;
}
diff --git a/web/src/modals.ts b/web/src/modals.ts
index 8b22a9a7c24..4c298a7e8df 100644
--- a/web/src/modals.ts
+++ b/web/src/modals.ts
@@ -31,12 +31,12 @@ function call_hooks(func_list: Hook[]): void {
}
}
-export function is_modal_open(): boolean {
+export function is_open(): boolean {
return $(".micromodal").hasClass("modal--open");
}
export function active_modal(): string | undefined {
- if (!is_modal_open()) {
+ if (!is_open()) {
blueslip.error("Programming error — Called active_modal when there is no modal open");
return undefined;
}
@@ -68,10 +68,10 @@ export function open_modal(
return;
}
- if (is_modal_open()) {
+ if (is_open()) {
/*
Our modal system doesn't directly support opening a modal
- when one is already open, because the `is_modal_open` CSS
+ when one is already open, because the `is_open` CSS
class doesn't update until Micromodal has finished its
animations, which can take 100ms or more.
@@ -178,8 +178,8 @@ export function close_modal(modal_id: string, conf: Pick<ModalConfig, "on_hidden
return;
}
- if (!is_modal_open()) {
- blueslip.warn("close_active_modal() called without checking is_modal_open()");
+ if (!is_open()) {
+ blueslip.warn("close_active_modal() called without checking is_open()");
return;
}
@@ -213,7 +213,7 @@ export function close_modal_if_open(modal_id: string): void {
return;
}
- if (!is_modal_open()) {
+ if (!is_open()) {
return;
}
@@ -229,8 +229,8 @@ export function close_modal_if_open(modal_id: string): void {
}
export function close_active_modal(): void {
- if (!is_modal_open()) {
- blueslip.warn("close_active_modal() called without checking is_modal_open()");
+ if (!is_open()) {
+ blueslip.warn("close_active_modal() called without checking is_open()");
return;
}
diff --git a/web/src/overlays_modals.ts b/web/src/overlays_modals.ts
index 4534187116a..5b01d7b0373 100644
--- a/web/src/overlays_modals.ts
+++ b/web/src/overlays_modals.ts
@@ -2,5 +2,5 @@ import * as modals from "./modals";
import * as overlays from "./overlays";
export function any_active(): boolean {
- return overlays.is_active() || modals.is_modal_open();
+ return overlays.is_active() || modals.is_open();
}
diff --git a/web/src/portico/portico_modals.ts b/web/src/portico/portico_modals.ts
index a232293646e..eb4a6e5dba4 100644
--- a/web/src/portico/portico_modals.ts
+++ b/web/src/portico/portico_modals.ts
@@ -3,12 +3,12 @@ import Micromodal from "micromodal";
import * as blueslip from "../blueslip";
-function is_modal_open(): boolean {
+function is_open(): boolean {
return $(".micromodal").hasClass("modal--open");
}
function active_modal(): string | undefined {
- if (!is_modal_open()) {
+ if (!is_open()) {
blueslip.error("Programming error — Called active_modal when there is no modal open");
return undefined;
}
@@ -18,8 +18,8 @@ function active_modal(): string | undefined {
}
function close_active_modal(): void {
- if (!is_modal_open()) {
- blueslip.warn("close_active_modal() called without checking is_modal_open()");
+ if (!is_open()) {
+ blueslip.warn("close_active_modal() called without checking is_open()");
return;
}
@@ -40,10 +40,10 @@ export function open_modal(modal_id: string, recursive_call_count: number = 0):
return;
}
- if (is_modal_open()) {
+ if (is_open()) {
/*
Our modal system doesn't directly support opening a modal
- when one is already open, because the `is_modal_open` CSS
+ when one is already open, because the `is_open` CSS
class doesn't update until Micromodal has finished its
animations, which can take 100ms or more.
@@ -118,8 +118,8 @@ export function close_modal(modal_id: string): void {
return;
}
- if (!is_modal_open()) {
- blueslip.warn("close_active_modal() called without checking is_modal_open()");
+ if (!is_open()) {
+ blueslip.warn("close_active_modal() called without checking is_open()");
return;
}
diff --git a/web/src/settings.js b/web/src/settings.js
index df3ceeb53d8..f98c4b3ed0e 100644
--- a/web/src/settings.js
+++ b/web/src/settings.js
@@ -26,7 +26,7 @@ export let settings_label;
$(() => {
$("#settings_overlay_container").on("click", (e) => {
- if (!modals.is_modal_open()) {
+ if (!modals.is_open()) {
return;
}
if ($(e.target).closest(".micromodal").length > 0) {
diff --git a/web/src/user_profile.js b/web/src/user_profile.js
index 16d59b52f9a..8f6aca674c7 100644
--- a/web/src/user_profile.js
+++ b/web/src/user_profile.js
@@ -74,7 +74,7 @@ function compare_by_name(a, b) {
}
export function get_user_id_if_user_profile_modal_open() {
- if (modals.is_modal_open() && modals.active_modal() === "#user-profile-modal") {
+ if (modals.is_open() && modals.active_modal() === "#user-profile-modal") {
const user_id = $("#user-profile-modal").data("user-id");
return user_id;
}
diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.js
index 32106631107..f497e7fcb51 100644
--- a/web/tests/hotkey.test.js
+++ b/web/tests/hotkey.test.js
@@ -56,7 +56,7 @@ const narrow_state = mock_esm("../src/narrow_state", {
});
const navigate = mock_esm("../src/navigate");
const modals = mock_esm("../src/modals", {
- is_modal_open: () => false,
+ is_open: () => false,
active_modal: () => undefined,
});
const overlays = mock_esm("../src/overlays", {
@@ -350,7 +350,7 @@ run_test("drafts closed launch", ({override}) => {
});
run_test("modal open", ({override}) => {
- override(modals, "is_modal_open", () => true);
+ override(modals, "is_open", () => true);
test_normal_typing();
});