mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
refactor: Move update_subscribers_list.
We should be able to solve the import back to stream_edit in an upcoming commit.
This commit is contained in:
@@ -31,6 +31,7 @@ import * as stream_edit from "./stream_edit";
|
||||
import * as stream_list from "./stream_list";
|
||||
import * as stream_muting from "./stream_muting";
|
||||
import * as stream_settings_data from "./stream_settings_data";
|
||||
import * as stream_subscribers_ui from "./stream_subscribers_ui";
|
||||
import * as stream_ui_updates from "./stream_ui_updates";
|
||||
import * as sub_store from "./sub_store";
|
||||
import * as ui from "./ui";
|
||||
@@ -227,7 +228,7 @@ export function set_color(stream_id, color) {
|
||||
|
||||
export function update_subscribers_ui(sub) {
|
||||
update_left_panel_row(sub);
|
||||
stream_ui_updates.update_subscribers_list(sub);
|
||||
stream_subscribers_ui.update_subscribers_list(sub);
|
||||
message_view_header.maybe_rerender_title_area_for_stream(sub);
|
||||
}
|
||||
|
||||
@@ -299,7 +300,7 @@ export function update_settings_for_subscribed(slim_sub) {
|
||||
add_sub_to_table(sub);
|
||||
}
|
||||
|
||||
stream_ui_updates.update_subscribers_list(sub);
|
||||
stream_subscribers_ui.update_subscribers_list(sub);
|
||||
|
||||
// Display the swatch and subscription stream_settings
|
||||
stream_ui_updates.update_regular_sub_settings(sub);
|
||||
@@ -317,7 +318,7 @@ export function show_active_stream_in_left_panel() {
|
||||
export function update_settings_for_unsubscribed(slim_sub) {
|
||||
const sub = stream_settings_data.get_sub_for_settings(slim_sub);
|
||||
update_left_panel_row(sub);
|
||||
stream_ui_updates.update_subscribers_list(sub);
|
||||
stream_subscribers_ui.update_subscribers_list(sub);
|
||||
stream_ui_updates.update_toggler_for_sub(sub);
|
||||
stream_ui_updates.update_settings_button_for_sub(sub);
|
||||
stream_ui_updates.update_regular_sub_settings(sub);
|
||||
|
||||
@@ -15,6 +15,8 @@ import * as peer_data from "./peer_data";
|
||||
import * as people from "./people";
|
||||
import * as pill_typeahead from "./pill_typeahead";
|
||||
import * as settings_data from "./settings_data";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_edit from "./stream_edit";
|
||||
import * as stream_pill from "./stream_pill";
|
||||
import * as sub_store from "./sub_store";
|
||||
import * as ui from "./ui";
|
||||
@@ -316,6 +318,39 @@ function remove_subscriber({stream_id, target_user_id, list_entry}) {
|
||||
remove_user_from_stream(target_user_id, sub, removal_success, removal_failure);
|
||||
}
|
||||
|
||||
export function update_subscribers_list(sub) {
|
||||
// This is for the "Stream membership" section of the right panel.
|
||||
// Render subscriptions only if stream settings is open
|
||||
if (!stream_edit.is_sub_settings_active(sub)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stream_data.can_view_subscribers(sub)) {
|
||||
$(".subscriber_list_settings_container").hide();
|
||||
} else {
|
||||
const subscriber_ids = peer_data.get_subscribers(sub.stream_id);
|
||||
const users = people.get_users_from_ids(subscriber_ids);
|
||||
|
||||
/*
|
||||
We try to find a subscribers list that is already in the
|
||||
cache that list_widget.js maintains. The list we are
|
||||
looking for would have been created in the function
|
||||
stream_edit.show_subscription_settings, using the same
|
||||
naming scheme as below for the `name` parameter.
|
||||
*/
|
||||
const subscribers_list = ListWidget.get("stream_subscribers/" + sub.stream_id);
|
||||
|
||||
// Changing the data clears the rendered list and the list needs to be re-rendered.
|
||||
// Perform re-rendering only when the stream settings form of the corresponding
|
||||
// stream is open.
|
||||
if (subscribers_list) {
|
||||
people.sort_but_pin_current_user_on_top(users);
|
||||
subscribers_list.replace_list_data(users);
|
||||
}
|
||||
$(".subscriber_list_settings_container").show();
|
||||
}
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
$("#subscriptions_table").on("keyup", ".subscriber_list_add form", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
|
||||
@@ -3,10 +3,7 @@ import $ from "jquery";
|
||||
import render_stream_permission_description from "../templates/stream_settings/stream_permission_description.hbs";
|
||||
|
||||
import {$t} from "./i18n";
|
||||
import * as ListWidget from "./list_widget";
|
||||
import {page_params} from "./page_params";
|
||||
import * as peer_data from "./peer_data";
|
||||
import * as people from "./people";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_edit from "./stream_edit";
|
||||
import * as stream_settings_containers from "./stream_settings_containers";
|
||||
@@ -168,39 +165,6 @@ export function update_stream_subscription_type_text(sub) {
|
||||
}
|
||||
}
|
||||
|
||||
export function update_subscribers_list(sub) {
|
||||
// This is for the "Stream membership" section of the right panel.
|
||||
// Render subscriptions only if stream settings is open
|
||||
if (!stream_edit.is_sub_settings_active(sub)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stream_data.can_view_subscribers(sub)) {
|
||||
$(".subscriber_list_settings_container").hide();
|
||||
} else {
|
||||
const subscriber_ids = peer_data.get_subscribers(sub.stream_id);
|
||||
const users = people.get_users_from_ids(subscriber_ids);
|
||||
|
||||
/*
|
||||
We try to find a subscribers list that is already in the
|
||||
cache that list_widget.js maintains. The list we are
|
||||
looking for would have been created in the function
|
||||
stream_edit.show_subscription_settings, using the same
|
||||
naming scheme as below for the `name` parameter.
|
||||
*/
|
||||
const subscribers_list = ListWidget.get("stream_subscribers/" + sub.stream_id);
|
||||
|
||||
// Changing the data clears the rendered list and the list needs to be re-rendered.
|
||||
// Perform re-rendering only when the stream settings form of the corresponding
|
||||
// stream is open.
|
||||
if (subscribers_list) {
|
||||
people.sort_but_pin_current_user_on_top(users);
|
||||
subscribers_list.replace_list_data(users);
|
||||
}
|
||||
$(".subscriber_list_settings_container").show();
|
||||
}
|
||||
}
|
||||
|
||||
export function update_add_subscriptions_elements(sub) {
|
||||
if (!stream_edit.is_sub_settings_active(sub)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user