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.

refactor: Remove is_sub_settings_active.

Steve Howellafd1d1240515
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index 621ff32ec3d..529559384b3 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -49,14 +49,6 @@ export function setup_subscriptions_tab_hash(tab_key_value) {
}
}
-export function is_sub_settings_active(sub) {
- // This function return whether the provided given sub object is
- // currently being viewed/edited in the stream edit UI. This is
- // used to determine whether we need to rerender the stream edit
- // UI when a sub object is modified by an event.
- return hash_util.is_editing_stream(sub.stream_id);
-}
-
export function get_retention_policy_text_for_subscription_type(sub) {
let message_retention_days = sub.message_retention_days;
// If both this stream and the organization-level policy are to retain forever,
diff --git a/static/js/stream_settings_ui.js b/static/js/stream_settings_ui.js
index 165018ae3a6..cd357f9e850 100644
--- a/static/js/stream_settings_ui.js
+++ b/static/js/stream_settings_ui.js
@@ -275,8 +275,7 @@ export function remove_stream(stream_id) {
// stream, but we let jQuery silently handle that.
const row = row_for_stream_id(stream_id);
row.remove();
- const sub = sub_store.get(stream_id);
- if (stream_edit.is_sub_settings_active(sub)) {
+ if (hash_util.is_editing_stream(stream_id)) {
stream_edit.open_edit_panel_empty();
}
}
diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js
index bcb086c4e98..afa88e93dfa 100644
--- a/static/js/stream_ui_updates.js
+++ b/static/js/stream_ui_updates.js
@@ -2,6 +2,7 @@ import $ from "jquery";
import render_stream_permission_description from "../templates/stream_settings/stream_permission_description.hbs";
+import * as hash_util from "./hash_util";
import {$t} from "./i18n";
import {page_params} from "./page_params";
import * as stream_data from "./stream_data";
@@ -52,7 +53,7 @@ export function initialize_cant_subscribe_popover(sub) {
}
export function update_toggler_for_sub(sub) {
- if (!stream_edit.is_sub_settings_active(sub)) {
+ if (!hash_util.is_editing_stream(sub.stream_id)) {
return;
}
if (sub.subscribed) {
@@ -92,7 +93,7 @@ export function update_settings_button_for_sub(sub) {
export function update_regular_sub_settings(sub) {
// These are in the right panel.
- if (!stream_edit.is_sub_settings_active(sub)) {
+ if (!hash_util.is_editing_stream(sub.stream_id)) {
return;
}
const $settings = $(`.subscription_settings[data-stream-id='${CSS.escape(sub.stream_id)}']`);
@@ -160,13 +161,13 @@ export function update_stream_subscription_type_text(sub) {
message_retention_text: stream_edit.get_retention_policy_text_for_subscription_type(sub),
};
const html = render_stream_permission_description(template_data);
- if (stream_edit.is_sub_settings_active(sub)) {
+ if (hash_util.is_editing_stream(sub.stream_id)) {
stream_settings.find(".subscription-type-text").expectOne().html(html);
}
}
export function update_add_subscriptions_elements(sub) {
- if (!stream_edit.is_sub_settings_active(sub)) {
+ if (!hash_util.is_editing_stream(sub.stream_id)) {
return;
}