mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	refactor: Migrate Bootstrap modal calls to overlay calls.
				
					
				
			In d0f8515b50, it was noticed that
Bootstrap's `hide` and `show` calls can cause race conditions.
So, migrate to our `overlay` calls to handle Bootstrap modals.
			
			
This commit is contained in:
		@@ -18,6 +18,7 @@ import * as markdown from "./markdown";
 | 
				
			|||||||
import * as message_lists from "./message_lists";
 | 
					import * as message_lists from "./message_lists";
 | 
				
			||||||
import * as message_store from "./message_store";
 | 
					import * as message_store from "./message_store";
 | 
				
			||||||
import * as message_viewport from "./message_viewport";
 | 
					import * as message_viewport from "./message_viewport";
 | 
				
			||||||
 | 
					import * as overlays from "./overlays";
 | 
				
			||||||
import {page_params} from "./page_params";
 | 
					import {page_params} from "./page_params";
 | 
				
			||||||
import * as resize from "./resize";
 | 
					import * as resize from "./resize";
 | 
				
			||||||
import * as rows from "./rows";
 | 
					import * as rows from "./rows";
 | 
				
			||||||
@@ -918,7 +919,7 @@ function hide_delete_btn_show_spinner(deleting) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function delete_message(msg_id) {
 | 
					export function delete_message(msg_id) {
 | 
				
			||||||
    $("#delete-message-error").html("");
 | 
					    $("#delete-message-error").html("");
 | 
				
			||||||
    $("#delete_message_modal").modal("show");
 | 
					    overlays.open_modal("#delete_message_modal");
 | 
				
			||||||
    if (currently_deleting_messages.includes(msg_id)) {
 | 
					    if (currently_deleting_messages.includes(msg_id)) {
 | 
				
			||||||
        hide_delete_btn_show_spinner(true);
 | 
					        hide_delete_btn_show_spinner(true);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@@ -934,7 +935,7 @@ export function delete_message(msg_id) {
 | 
				
			|||||||
            channel.del({
 | 
					            channel.del({
 | 
				
			||||||
                url: "/json/messages/" + msg_id,
 | 
					                url: "/json/messages/" + msg_id,
 | 
				
			||||||
                success() {
 | 
					                success() {
 | 
				
			||||||
                    $("#delete_message_modal").modal("hide");
 | 
					                    overlays.close_modal("#delete_message_modal");
 | 
				
			||||||
                    currently_deleting_messages = currently_deleting_messages.filter(
 | 
					                    currently_deleting_messages = currently_deleting_messages.filter(
 | 
				
			||||||
                        (id) => id !== msg_id,
 | 
					                        (id) => id !== msg_id,
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
@@ -962,7 +963,7 @@ export function delete_topic(stream_id, topic_name) {
 | 
				
			|||||||
            topic_name,
 | 
					            topic_name,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        success() {
 | 
					        success() {
 | 
				
			||||||
            $("#delete_topic_modal").modal("hide");
 | 
					            overlays.close_modal("#delete_topic_modal");
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -988,7 +989,7 @@ export function move_topic_containing_message_to_stream(
 | 
				
			|||||||
            (id) => id !== message_id,
 | 
					            (id) => id !== message_id,
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        hide_topic_move_spinner();
 | 
					        hide_topic_move_spinner();
 | 
				
			||||||
        $("#move_topic_modal").modal("hide");
 | 
					        overlays.close_modal("#move_topic_modal");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (currently_topic_editing_messages.includes(message_id)) {
 | 
					    if (currently_topic_editing_messages.includes(message_id)) {
 | 
				
			||||||
        hide_topic_move_spinner();
 | 
					        hide_topic_move_spinner();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ import render_message_edit_history from "../templates/message_edit_history.hbs";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import * as channel from "./channel";
 | 
					import * as channel from "./channel";
 | 
				
			||||||
import {$t_html} from "./i18n";
 | 
					import {$t_html} from "./i18n";
 | 
				
			||||||
 | 
					import * as overlays from "./overlays";
 | 
				
			||||||
import * as people from "./people";
 | 
					import * as people from "./people";
 | 
				
			||||||
import * as timerender from "./timerender";
 | 
					import * as timerender from "./timerender";
 | 
				
			||||||
import * as ui_report from "./ui_report";
 | 
					import * as ui_report from "./ui_report";
 | 
				
			||||||
@@ -74,6 +75,6 @@ export function fetch_and_render_message_history(message) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function show_history(message) {
 | 
					export function show_history(message) {
 | 
				
			||||||
    $("#message-history").html("");
 | 
					    $("#message-history").html("");
 | 
				
			||||||
    $("#message-edit-history").modal("show");
 | 
					    overlays.open_modal("#message-edit-history");
 | 
				
			||||||
    fetch_and_render_message_history(message);
 | 
					    fetch_and_render_message_history(message);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -369,7 +369,7 @@ export function hide_mobile_message_buttons_popover() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function hide_user_profile() {
 | 
					export function hide_user_profile() {
 | 
				
			||||||
    $("#user-profile-modal").modal("hide");
 | 
					    overlays.close_modal("#user-profile-modal");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function show_user_profile(user) {
 | 
					export function show_user_profile(user) {
 | 
				
			||||||
@@ -396,7 +396,7 @@ export function show_user_profile(user) {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $("#user-profile-modal-holder").html(render_user_profile_modal(args));
 | 
					    $("#user-profile-modal-holder").html(render_user_profile_modal(args));
 | 
				
			||||||
    $("#user-profile-modal").modal("show");
 | 
					    overlays.open_modal("#user-profile-modal");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    settings_account.initialize_custom_user_type_fields(
 | 
					    settings_account.initialize_custom_user_type_fields(
 | 
				
			||||||
        "#user-profile-modal #content",
 | 
					        "#user-profile-modal #content",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -558,7 +558,7 @@ export function set_up() {
 | 
				
			|||||||
        // will not show up because of a call to `close_active_modal` in `settings.js`.
 | 
					        // will not show up because of a call to `close_active_modal` in `settings.js`.
 | 
				
			||||||
        e.preventDefault();
 | 
					        e.preventDefault();
 | 
				
			||||||
        e.stopPropagation();
 | 
					        e.stopPropagation();
 | 
				
			||||||
        $("#deactivate_self_modal").modal("show");
 | 
					        overlays.open_modal("#deactivate_self_modal");
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $("#account-settings").on("click", ".custom_user_field .remove_date", (e) => {
 | 
					    $("#account-settings").on("click", ".custom_user_field .remove_date", (e) => {
 | 
				
			||||||
@@ -598,7 +598,7 @@ export function set_up() {
 | 
				
			|||||||
            channel.del({
 | 
					            channel.del({
 | 
				
			||||||
                url: "/json/users/me",
 | 
					                url: "/json/users/me",
 | 
				
			||||||
                success() {
 | 
					                success() {
 | 
				
			||||||
                    $("#deactivate_self_modal").modal("hide");
 | 
					                    overlays.close_modal("#deactivate_self_modal");
 | 
				
			||||||
                    window.location.href = "/login/";
 | 
					                    window.location.href = "/login/";
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                error(xhr) {
 | 
					                error(xhr) {
 | 
				
			||||||
@@ -623,7 +623,7 @@ export function set_up() {
 | 
				
			|||||||
                            rendered_error_msg = error_last_user;
 | 
					                            rendered_error_msg = error_last_user;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    $("#deactivate_self_modal").modal("hide");
 | 
					                    overlays.close_modal("#deactivate_self_modal");
 | 
				
			||||||
                    $("#account-settings-status")
 | 
					                    $("#account-settings-status")
 | 
				
			||||||
                        .addClass("alert-error")
 | 
					                        .addClass("alert-error")
 | 
				
			||||||
                        .html(rendered_error_msg)
 | 
					                        .html(rendered_error_msg)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@ import {$t, $t_html} from "./i18n";
 | 
				
			|||||||
import * as message_edit from "./message_edit";
 | 
					import * as message_edit from "./message_edit";
 | 
				
			||||||
import * as muting from "./muting";
 | 
					import * as muting from "./muting";
 | 
				
			||||||
import * as muting_ui from "./muting_ui";
 | 
					import * as muting_ui from "./muting_ui";
 | 
				
			||||||
 | 
					import * as overlays from "./overlays";
 | 
				
			||||||
import {page_params} from "./page_params";
 | 
					import {page_params} from "./page_params";
 | 
				
			||||||
import * as popovers from "./popovers";
 | 
					import * as popovers from "./popovers";
 | 
				
			||||||
import * as resize from "./resize";
 | 
					import * as resize from "./resize";
 | 
				
			||||||
@@ -363,7 +364,7 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    stream_bar.decorate(current_stream_name, stream_header_colorblock, false);
 | 
					    stream_bar.decorate(current_stream_name, stream_header_colorblock, false);
 | 
				
			||||||
    $("#move_topic_modal").modal("show");
 | 
					    overlays.open_modal("#move_topic_modal");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function register_click_handlers() {
 | 
					export function register_click_handlers() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ import {$t} from "./i18n";
 | 
				
			|||||||
import {localstorage} from "./localstorage";
 | 
					import {localstorage} from "./localstorage";
 | 
				
			||||||
import * as message_list from "./message_list";
 | 
					import * as message_list from "./message_list";
 | 
				
			||||||
import * as message_lists from "./message_lists";
 | 
					import * as message_lists from "./message_lists";
 | 
				
			||||||
 | 
					import * as overlays from "./overlays";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// What, if anything, obscures the home tab?
 | 
					// What, if anything, obscures the home tab?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -144,7 +145,7 @@ export function maybe_show_deprecation_notice(key) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!shown_deprecation_notices.includes(key)) {
 | 
					    if (!shown_deprecation_notices.includes(key)) {
 | 
				
			||||||
        $("#deprecation-notice-modal").modal("show");
 | 
					        overlays.open_modal("#deprecation-notice-modal");
 | 
				
			||||||
        $("#deprecation-notice-message").text(message);
 | 
					        $("#deprecation-notice-message").text(message);
 | 
				
			||||||
        $("#close-deprecation-notice").trigger("focus");
 | 
					        $("#close-deprecation-notice").trigger("focus");
 | 
				
			||||||
        shown_deprecation_notices.push(key);
 | 
					        shown_deprecation_notices.push(key);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user