Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic_popover: Show loading indicicator on topic resolve/unresolve.
Sayam Samal5d4b9ee505a5
diff --git a/web/shared/icons/placeholder.svg b/web/shared/icons/placeholder.svgnew file mode 100644index 00000000000..42d92797115--- /dev/null+++ b/web/shared/icons/placeholder.svg@@ -0,0 +1,3 @@+<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">+<path d="M8.1 8.05C8.1 8.07761 8.07761 8.1 8.05 8.1C8.02239 8.1 8 8.07761 8 8.05C8 8.02239 8.02239 8 8.05 8C8.07761 8 8.1 8.02239 8.1 8.05Z"/>+</svg>diff --git a/web/src/message_edit.ts b/web/src/message_edit.tsindex 62a6949547d..c516b2e01a0 100644--- a/web/src/message_edit.ts+++ b/web/src/message_edit.ts@@ -764,8 +764,17 @@ export function start($row: JQuery, edit_box_open_callback?: () => void): void {});}-function show_toggle_resolve_topic_spinner($row: JQuery): void {- const $button = $row.find(".on_hover_topic_resolve").expectOne();+function show_toggle_resolve_topic_spinner($row: JQuery, topic_is_resolved: boolean): void {+ let $button: JQuery;+ if (topic_is_resolved) {+ // Since we don't show a separate unresolve topic button in the recipient bar,+ // this code path is only reached when the user unresolves a topic using the+ // "Mark as unresolved" option from the recipient bar topic actions menu.+ $button = $row.find(".on-hover-unresolve-loading-indicator").expectOne();+ $button.removeClass("hide");+ } else {+ $button = $row.find(".on_hover_topic_resolve").expectOne();+ }$button.addClass("loading-resolve-topic-state");// While we call the show_button_loading_indicator method to// show the spinner, we don't need to call the corresponding@@ -924,7 +933,7 @@ function do_toggle_resolve_topic($row?: JQuery,): void {if ($row) {- show_toggle_resolve_topic_spinner($row);+ show_toggle_resolve_topic_spinner($row, topic_is_resolved);}const request = {diff --git a/web/src/topic_popover.ts b/web/src/topic_popover.tsindex e2a1cfc9779..1693cd837dd 100644--- a/web/src/topic_popover.ts+++ b/web/src/topic_popover.ts@@ -72,6 +72,7 @@ export function initialize(): void {);},onMount(instance) {+ const $reference = $(instance.reference);const $popper = $(instance.popper);const {stream_id, topic_name, url} = get_conversation(instance);const context = popover_menus_data.get_topic_popover_content_context({@@ -183,7 +184,19 @@ export function initialize(): void {$popper.one("click", ".sidebar-popover-toggle-resolved", () => {message_edit.with_first_message_id(stream_id, topic_name, (message_id) => {assert(message_id !== undefined);- message_edit.toggle_resolve_topic(message_id, topic_name, true);+ let $recipient_row;+ if ($reference.hasClass("recipient-row-topic-menu")) {+ // If the popover was opened from the recipient row, we+ // we pass the recipient row to the toggle_resolve_topic+ // function to show the loading indicator accordingly.+ $recipient_row = $reference.closest(".recipient_row");+ }+ message_edit.toggle_resolve_topic(+ message_id,+ topic_name,+ true,+ $recipient_row,+ );});popover_menus.hide_current_popover_if_visible(instance);diff --git a/web/templates/recipient_row.hbs b/web/templates/recipient_row.hbsindex 76b85482484..a819a26ae0c 100644--- a/web/templates/recipient_row.hbs+++ b/web/templates/recipient_row.hbs@@ -55,9 +55,11 @@{{/if}}{{#if (and user_can_resolve_topic (not is_empty_string_topic))}}- {{#unless topic_is_resolved}}+ {{#if topic_is_resolved}}+ {{> components/icon_button icon="placeholder" intent="neutral" custom_classes="recipient-bar-control on-hover-unresolve-loading-indicator hidden-for-spectators hide" }}+ {{else}}{{> components/icon_button icon="check" intent="neutral" custom_classes="on_hover_topic_resolve recipient-bar-control recipient-bar-control-icon hidden-for-spectators" data-tippy-content=(t "Mark as resolved") aria-label=(t "Mark as resolved") }}- {{/unless}}+ {{/if}}{{/if}}{{! visibility policy menu }}