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_create: Do not show banner if the current user is subscribed.

Sahil Batra70b6e4651692
diff --git a/web/src/stream_create.ts b/web/src/stream_create.ts
index 75e5b08115b..2f58be4d7d0 100644
--- a/web/src/stream_create.ts
+++ b/web/src/stream_create.ts
@@ -22,6 +22,9 @@ import * as ui_report from "./ui_report";
import * as util from "./util";
let created_stream: string | undefined;
+// Default is true since the current user is added to
+// the subscribers list initially.
+let current_user_subscribed_to_created_stream = true;
export function reset_created_stream(): void {
created_stream = undefined;
@@ -35,6 +38,18 @@ export function get_name(): string | undefined {
return created_stream;
}
+export function reset_current_user_subscribed_to_created_stream(): void {
+ current_user_subscribed_to_created_stream = true;
+}
+
+export function set_current_user_subscribed_to_created_stream(is_subscribed: boolean): void {
+ current_user_subscribed_to_created_stream = is_subscribed;
+}
+
+export function get_current_user_subscribed_to_created_stream(): boolean {
+ return current_user_subscribed_to_created_stream;
+}
+
export function set_first_stream_created_modal_shown(): void {
onboarding_steps.post_onboarding_step_as_read("first_stream_created_banner");
}
@@ -317,6 +332,7 @@ function create_stream(): void {
// once we upgrade the backend to accept user_ids.
const user_ids = stream_create_subscribers.get_principals();
const principals = JSON.stringify(user_ids);
+ set_current_user_subscribed_to_created_stream(user_ids.includes(current_user.user_id));
assert(stream_settings_components.new_stream_can_remove_subscribers_group_widget !== null);
const widget_value =
diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.js
index 67bbe716405..7ee0f08f446 100644
--- a/web/src/stream_settings_ui.js
+++ b/web/src/stream_settings_ui.js
@@ -239,18 +239,25 @@ export function add_sub_to_table(sub) {
// top of the list, so they are more visible.
stream_ui_updates.row_for_stream_id(sub.stream_id).trigger("click");
- // This banner is for administrators creating a channel that
- // they are themselves not initial subscribers to; other users
- // will be immediately navigated to the channel view.
- const context = {
- banner_type: compose_banner.SUCCESS,
- classname: "stream_creation_confirmation",
- stream_name: sub.name,
- stream_url: hash_util.by_stream_url(sub.stream_id),
- };
- $("#stream_settings .stream-creation-confirmation-banner").html(
- render_stream_creation_confirmation_banner(context),
- );
+ if (!stream_create.get_current_user_subscribed_to_created_stream()) {
+ // This banner is for administrators creating a channel that
+ // they are themselves not initial subscribers to; other users
+ // will be immediately navigated to the channel view.
+ //
+ // stream_create.get_current_user_subscribed_to_created_stream
+ // is just a work around because we do not have the subscribers
+ // info yet.
+ const context = {
+ banner_type: compose_banner.SUCCESS,
+ classname: "stream_creation_confirmation",
+ stream_name: sub.name,
+ stream_url: hash_util.by_stream_url(sub.stream_id),
+ };
+ $("#stream_settings .stream-creation-confirmation-banner").html(
+ render_stream_creation_confirmation_banner(context),
+ );
+ }
+ stream_create.reset_current_user_subscribed_to_created_stream();
}
update_empty_left_panel_message();
}