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-settings: Rename variable and functions for filter.

Sahil Batra8e3176a8edb7
diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.ts
index 14455d52c58..5208f193b95 100644
--- a/web/src/stream_settings_components.ts
+++ b/web/src/stream_settings_components.ts
@@ -28,7 +28,7 @@ import type {StreamSubscription} from "./sub_store.ts";
import * as ui_report from "./ui_report.ts";
import * as user_groups from "./user_groups.ts";
-export let filter_dropdown_widget: DropdownWidget;
+export let archived_status_filter_dropdown_widget: DropdownWidget;
export function set_right_panel_title(sub: StreamSubscription): void {
let title_icon_color = "#333333";
@@ -291,25 +291,25 @@ export function sub_or_unsub(
}
}
-export function set_filter_dropdown_widget(widget: DropdownWidget): void {
- filter_dropdown_widget = widget;
+export function set_archived_status_filter_dropdown_widget(widget: DropdownWidget): void {
+ archived_status_filter_dropdown_widget = widget;
}
-export function get_filter_dropdown_value(): string {
- return z.string().parse(filter_dropdown_widget.value());
+export function get_archived_status_filter_dropdown_value(): string {
+ return z.string().parse(archived_status_filter_dropdown_widget.value());
}
-export function set_filter_dropdown_value(value: string): void {
- filter_dropdown_widget.render(value);
+export function set_archived_status_filter_dropdown_value(value: string): void {
+ archived_status_filter_dropdown_widget.render(value);
}
-export function set_filters_for_tests(filter_widget: DropdownWidget): void {
- filter_dropdown_widget = filter_widget;
+export function set_archived_status_filters_for_tests(filter_widget: DropdownWidget): void {
+ archived_status_filter_dropdown_widget = filter_widget;
}
-export function filter_includes_channel(sub: StreamSubscription): boolean {
- const filter_value = get_filter_dropdown_value();
- const FILTERS = stream_settings_data.FILTERS;
+export function archived_status_filter_includes_channel(sub: StreamSubscription): boolean {
+ const filter_value = get_archived_status_filter_dropdown_value();
+ const FILTERS = stream_settings_data.ARCHIVED_STATUS_FILTERS;
if (
(filter_value === FILTERS.NON_ARCHIVED_CHANNELS && sub.is_archived) ||
(filter_value === FILTERS.ARCHIVED_CHANNELS && !sub.is_archived)
diff --git a/web/src/stream_settings_data.ts b/web/src/stream_settings_data.ts
index 9e756d5c0ed..eead3922970 100644
--- a/web/src/stream_settings_data.ts
+++ b/web/src/stream_settings_data.ts
@@ -29,7 +29,7 @@ export type SettingsSubscription = StreamSubscription & {
subscriber_count: number;
};
-export const FILTERS = {
+export const ARCHIVED_STATUS_FILTERS = {
ALL_CHANNELS: "all_channels",
NON_ARCHIVED_CHANNELS: "non_archived_channels",
ARCHIVED_CHANNELS: "archived_channels",
diff --git a/web/src/stream_settings_ui.ts b/web/src/stream_settings_ui.ts
index 8966ef9b47e..ef7aec4f8e8 100644
--- a/web/src/stream_settings_ui.ts
+++ b/web/src/stream_settings_ui.ts
@@ -353,7 +353,7 @@ export function add_sub_to_table(sub: StreamSubscription): void {
const html = render_browse_streams_list_item(setting_sub);
const $new_row = $(html);
- if (stream_settings_components.filter_includes_channel(sub)) {
+ if (stream_settings_components.archived_status_filter_includes_channel(sub)) {
if (stream_create.get_name() === sub.name) {
scroll_util.get_content_element($(".streams-list")).prepend($new_row);
scroll_util.reset_scrollbar($(".streams-list"));
@@ -463,8 +463,8 @@ export function update_settings_for_archived_and_unarchived(slim_sub: StreamSubs
$(".stream_settings_filter_container").removeClass("hide_filter");
} else {
$(".stream_settings_filter_container").addClass("hide_filter");
- stream_settings_components.set_filter_dropdown_value(
- stream_settings_data.FILTERS.NON_ARCHIVED_CHANNELS,
+ stream_settings_components.set_archived_status_filter_dropdown_value(
+ stream_settings_data.ARCHIVED_STATUS_FILTERS.NON_ARCHIVED_CHANNELS,
);
}
redraw_left_panel();
@@ -517,8 +517,8 @@ export function update_settings_for_unsubscribed(slim_sub: StreamSubscription):
function triage_stream(left_panel_params: LeftPanelParams, sub: StreamSubscription): string {
const current_channel_visibility_filter =
- stream_settings_components.get_filter_dropdown_value();
- const channel_visibility_filters = stream_settings_data.FILTERS;
+ stream_settings_components.get_archived_status_filter_dropdown_value();
+ const channel_visibility_filters = stream_settings_data.ARCHIVED_STATUS_FILTERS;
if (
current_channel_visibility_filter === channel_visibility_filters.NON_ARCHIVED_CHANNELS &&
sub.is_archived
@@ -641,8 +641,8 @@ export function update_empty_left_panel_message(): void {
const has_search_query =
$<HTMLInputElement>("#stream_filter input[type='text']").val()!.trim() !== "";
const has_filter =
- stream_settings_components.get_filter_dropdown_value() !==
- stream_settings_data.FILTERS.ALL_CHANNELS;
+ stream_settings_components.get_archived_status_filter_dropdown_value() !==
+ stream_settings_data.ARCHIVED_STATUS_FILTERS.ALL_CHANNELS;
// Both search queries and filters can lead to all channels being hidden.
if (all_channels_hidden && (has_search_query || (has_filter && has_streams))) {
@@ -799,21 +799,23 @@ function filters_dropdown_options(
): dropdown_widget.Option[] {
return [
{
- unique_id: stream_settings_data.FILTERS.ARCHIVED_CHANNELS,
+ unique_id: stream_settings_data.ARCHIVED_STATUS_FILTERS.ARCHIVED_CHANNELS,
name: $t({defaultMessage: "Archived channels"}),
bold_current_selection:
- current_value === stream_settings_data.FILTERS.ARCHIVED_CHANNELS,
+ current_value === stream_settings_data.ARCHIVED_STATUS_FILTERS.ARCHIVED_CHANNELS,
},
{
- unique_id: stream_settings_data.FILTERS.NON_ARCHIVED_CHANNELS,
+ unique_id: stream_settings_data.ARCHIVED_STATUS_FILTERS.NON_ARCHIVED_CHANNELS,
name: $t({defaultMessage: "Non-archived channels"}),
bold_current_selection:
- current_value === stream_settings_data.FILTERS.NON_ARCHIVED_CHANNELS,
+ current_value ===
+ stream_settings_data.ARCHIVED_STATUS_FILTERS.NON_ARCHIVED_CHANNELS,
},
{
- unique_id: stream_settings_data.FILTERS.ALL_CHANNELS,
+ unique_id: stream_settings_data.ARCHIVED_STATUS_FILTERS.ALL_CHANNELS,
name: $t({defaultMessage: "Archived and non-archived"}),
- bold_current_selection: current_value === stream_settings_data.FILTERS.ALL_CHANNELS,
+ bold_current_selection:
+ current_value === stream_settings_data.ARCHIVED_STATUS_FILTERS.ALL_CHANNELS,
},
];
}
@@ -840,10 +842,10 @@ function set_up_dropdown_widget(): void {
widget_name: "stream_settings_filter",
item_click_callback: filter_click_handler,
$events_container: $("#stream_filter"),
- default_id: stream_settings_data.FILTERS.NON_ARCHIVED_CHANNELS,
+ default_id: stream_settings_data.ARCHIVED_STATUS_FILTERS.NON_ARCHIVED_CHANNELS,
});
widget.setup();
- stream_settings_components.set_filter_dropdown_widget(widget);
+ stream_settings_components.set_archived_status_filter_dropdown_widget(widget);
}
function setup_page(callback: () => void): void {
@@ -1082,15 +1084,15 @@ export function change_state(
switch_to_stream_row(stream_id);
const sub = stream_data.get_sub_by_id(stream_id);
- if (sub && !stream_settings_components.filter_includes_channel(sub)) {
- const FILTERS = stream_settings_data.FILTERS;
+ if (sub && !stream_settings_components.archived_status_filter_includes_channel(sub)) {
+ const FILTERS = stream_settings_data.ARCHIVED_STATUS_FILTERS;
let selected_filter;
if (sub.is_archived) {
selected_filter = FILTERS.ARCHIVED_CHANNELS;
} else {
selected_filter = FILTERS.NON_ARCHIVED_CHANNELS;
}
- stream_settings_components.set_filter_dropdown_value(selected_filter);
+ stream_settings_components.set_archived_status_filter_dropdown_value(selected_filter);
}
return;
}
diff --git a/web/src/stream_ui_updates.ts b/web/src/stream_ui_updates.ts
index 9e4b73281e3..356542db0f7 100644
--- a/web/src/stream_ui_updates.ts
+++ b/web/src/stream_ui_updates.ts
@@ -476,7 +476,7 @@ export function update_stream_row_in_settings_tab(sub: StreamSubscription): void
!sub.subscribed &&
stream_data.can_toggle_subscription(sub))
) {
- if (stream_settings_components.filter_includes_channel(sub)) {
+ if (stream_settings_components.archived_status_filter_includes_channel(sub)) {
$row.removeClass("notdisplayed");
}
} else if (current_user.is_guest || !stream_data.can_toggle_subscription(sub)) {
diff --git a/web/tests/stream_settings_ui.test.cjs b/web/tests/stream_settings_ui.test.cjs
index 90a960dd5b3..80a4bd537c4 100644
--- a/web/tests/stream_settings_ui.test.cjs
+++ b/web/tests/stream_settings_ui.test.cjs
@@ -228,7 +228,7 @@ run_test("redraw_left_panel", ({override, mock_template}) => {
render: function render() {},
value: () => "",
};
- stream_settings_components.set_filters_for_tests(filters_dropdown_widget);
+ stream_settings_components.set_archived_status_filters_for_tests(filters_dropdown_widget);
stream_settings_ui.render_left_panel_superset();