Skip to content

Commit

Permalink
dialog_widget: Check if modal is open before closing.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanagr committed Apr 27, 2024
1 parent 88e91fa commit 0a6f4c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions web/src/dialog_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export function show_dialog_spinner(): void {
});
}

export function is_open(): boolean {
return modals.any_active() && modals.active_modal() === "#dialog_widget_modal";
}

// Supports a callback to be called once the modal finishes closing.
export function close(on_hidden_callback?: () => void): void {
modals.close("dialog_widget_modal", {on_hidden: on_hidden_callback});
Expand Down
5 changes: 4 additions & 1 deletion web/src/unread_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ function bulk_update_read_flags_for_narrow(narrow, op, args = {}) {
blueslip.log("Cleared old_unreads_missing after bankruptcy.");
}
}
dialog_widget.close();

if (dialog_widget.is_open()) {
dialog_widget.close();
}
},
error(xhr) {
if (xhr.readyState === 0) {
Expand Down

0 comments on commit 0a6f4c3

Please sign in to comment.