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.

stream-edit: Fix spinner appearing unnecessarily in stream row.

Sahil Batra9a747831cee6
diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.ts
index dfea774fbcd..9aa2d123ece 100644
--- a/web/src/stream_edit.ts
+++ b/web/src/stream_edit.ts
@@ -776,15 +776,9 @@ export function initialize(): void {
const $target = $(event.target).parents(".main-view-banner");
const stream_id = Number.parseInt($target.attr("data-stream-id")!, 10);
- // Makes sure we take the correct stream_row.
- const $stream_row = $(
- `#channels_overlay_container div.stream-row[data-stream-id='${CSS.escape(
- stream_id.toString(),
- )}']`,
- );
const sub = sub_store.get(stream_id);
assert(sub !== undefined);
- stream_settings_components.sub_or_unsub(sub, $stream_row);
+ stream_settings_components.sub_or_unsub(sub);
$("#stream_settings .stream-permissions-warning-banner").empty();
},
);
@@ -852,7 +846,16 @@ export function initialize(): void {
sub.stream_id.toString(),
)}']`,
);
- stream_settings_components.sub_or_unsub(sub, $stream_row);
+
+ if ($(this).hasClass("action-button")) {
+ // If user tries to subscribe or unsubscribe using the
+ // button in the right side subheader, we do not pass
+ // $stream_row as we do not want the spinner to appear
+ // replacing the checkmark.
+ stream_settings_components.sub_or_unsub(sub);
+ } else {
+ stream_settings_components.sub_or_unsub(sub, $stream_row);
+ }
if (!sub.subscribed) {
open_edit_panel_for_row(util.the($stream_row));
diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.ts
index 9d5c2435b80..633467bd59f 100644
--- a/web/src/stream_settings_components.ts
+++ b/web/src/stream_settings_components.ts
@@ -274,7 +274,10 @@ function ajaxUnsubscribe(sub: StreamSubscription, $stream_row: JQuery | undefine
});
}
-export function unsubscribe_from_private_stream(sub: StreamSubscription): void {
+export function unsubscribe_from_private_stream(
+ sub: StreamSubscription,
+ $stream_row: JQuery | undefined,
+): void {
const invite_only = sub.invite_only;
const sub_count = peer_data.get_subscriber_count(sub.stream_id);
const stream_name_with_privacy_symbol_html = render_decorated_channel_name({
@@ -292,15 +295,6 @@ export function unsubscribe_from_private_stream(sub: StreamSubscription): void {
});
function unsubscribe_from_stream(): void {
- let $stream_row;
- if (overlays.streams_open()) {
- $stream_row = $(
- "#channels_overlay_container div.stream-row[data-stream-id='" +
- sub.stream_id +
- "']",
- );
- }
-
ajaxUnsubscribe(sub, $stream_row);
}
@@ -321,7 +315,7 @@ export function sub_or_unsub(sub: StreamSubscription, $stream_row?: JQuery): voi
(sub.invite_only && !stream_data.has_content_access_via_group_permissions(sub)) ||
current_user.is_guest
) {
- unsubscribe_from_private_stream(sub);
+ unsubscribe_from_private_stream(sub, $stream_row);
return;
}
ajaxUnsubscribe(sub, $stream_row);