mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	subs: Rename subs.js to stream_settings_ui.js.
We use subs as a common variable name for a collection of stream data structure used in settings, in lot of modules. So this rename clears a bunch of related shadowed variables.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							a41d5e58f9
						
					
				
				
					commit
					781179c56a
				
			@@ -39,7 +39,7 @@ const sent_messages = mock_esm("../../static/js/sent_messages");
 | 
			
		||||
const server_events = mock_esm("../../static/js/server_events");
 | 
			
		||||
const settings_data = mock_esm("../../static/js/settings_data");
 | 
			
		||||
const stream_edit = mock_esm("../../static/js/stream_edit");
 | 
			
		||||
const subs = mock_esm("../../static/js/subs");
 | 
			
		||||
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui");
 | 
			
		||||
const transmit = mock_esm("../../static/js/transmit");
 | 
			
		||||
 | 
			
		||||
const compose_closed_ui = zrequire("compose_closed_ui");
 | 
			
		||||
@@ -1105,7 +1105,7 @@ test_ui("on_events", ({override}) => {
 | 
			
		||||
            subscribed: false,
 | 
			
		||||
        };
 | 
			
		||||
        let compose_not_subscribed_called = false;
 | 
			
		||||
        subs.sub_or_unsub = () => {
 | 
			
		||||
        stream_settings_ui.sub_or_unsub = () => {
 | 
			
		||||
            compose_not_subscribed_called = true;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ const settings_org = mock_esm("../../static/js/settings_org");
 | 
			
		||||
const settings_streams = mock_esm("../../static/js/settings_streams");
 | 
			
		||||
const stream_events = mock_esm("../../static/js/stream_events");
 | 
			
		||||
const stream_list = mock_esm("../../static/js/stream_list");
 | 
			
		||||
const subs = mock_esm("../../static/js/subs");
 | 
			
		||||
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui");
 | 
			
		||||
message_lists.current = {};
 | 
			
		||||
 | 
			
		||||
const peer_data = zrequire("peer_data");
 | 
			
		||||
@@ -79,7 +79,7 @@ test("peer add/remove", ({override}) => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const subs_stub = make_stub();
 | 
			
		||||
    override(subs, "update_subscribers_ui", subs_stub.f);
 | 
			
		||||
    override(stream_settings_ui, "update_subscribers_ui", subs_stub.f);
 | 
			
		||||
 | 
			
		||||
    const compose_fade_stub = make_stub();
 | 
			
		||||
    override(compose_fade, "update_faded_users", compose_fade_stub.f);
 | 
			
		||||
@@ -186,7 +186,7 @@ test("stream create", ({override}) => {
 | 
			
		||||
 | 
			
		||||
    const stub = make_stub();
 | 
			
		||||
    override(stream_data, "create_streams", stub.f);
 | 
			
		||||
    override(subs, "add_sub_to_table", noop);
 | 
			
		||||
    override(stream_settings_ui, "add_sub_to_table", noop);
 | 
			
		||||
    override(overlays, "streams_open", () => true);
 | 
			
		||||
    dispatch(event);
 | 
			
		||||
    assert.equal(stub.num_calls, 1);
 | 
			
		||||
@@ -218,7 +218,7 @@ test("stream delete (normal)", ({override}) => {
 | 
			
		||||
 | 
			
		||||
    const removed_stream_ids = [];
 | 
			
		||||
 | 
			
		||||
    override(subs, "remove_stream", (stream_id) => {
 | 
			
		||||
    override(stream_settings_ui, "remove_stream", (stream_id) => {
 | 
			
		||||
        removed_stream_ids.push(stream_id);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@@ -250,7 +250,7 @@ test("stream delete (special streams)", ({override}) => {
 | 
			
		||||
    page_params.realm_notifications_stream_id = event.streams[0].stream_id;
 | 
			
		||||
    page_params.realm_signup_notifications_stream_id = event.streams[1].stream_id;
 | 
			
		||||
 | 
			
		||||
    override(subs, "remove_stream", noop);
 | 
			
		||||
    override(stream_settings_ui, "remove_stream", noop);
 | 
			
		||||
    override(settings_org, "sync_realm_settings", noop);
 | 
			
		||||
    override(settings_streams, "update_default_streams_table", noop);
 | 
			
		||||
    override(message_lists.current, "update_trailing_bookend", noop);
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ const message_viewport = mock_esm("../../static/js/message_viewport");
 | 
			
		||||
const narrow = mock_esm("../../static/js/narrow");
 | 
			
		||||
const overlays = mock_esm("../../static/js/overlays");
 | 
			
		||||
const settings = mock_esm("../../static/js/settings");
 | 
			
		||||
const subs = mock_esm("../../static/js/subs");
 | 
			
		||||
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui");
 | 
			
		||||
const ui_util = mock_esm("../../static/js/ui_util");
 | 
			
		||||
mock_esm("../../static/js/top_left_corner", {
 | 
			
		||||
    handle_narrow_deactivated: () => {},
 | 
			
		||||
@@ -137,7 +137,7 @@ function test_helper({override, change_tab}) {
 | 
			
		||||
    stub(narrow, "deactivate");
 | 
			
		||||
    stub(overlays, "close_for_hash_change");
 | 
			
		||||
    stub(settings, "launch");
 | 
			
		||||
    stub(subs, "launch");
 | 
			
		||||
    stub(stream_settings_ui, "launch");
 | 
			
		||||
    stub(ui_util, "blur_active_element");
 | 
			
		||||
 | 
			
		||||
    if (change_tab) {
 | 
			
		||||
@@ -244,7 +244,7 @@ run_test("hash_interactions", ({override}) => {
 | 
			
		||||
    window_stub.trigger("hashchange");
 | 
			
		||||
    helper.assert_events([
 | 
			
		||||
        [overlays, "close_for_hash_change"],
 | 
			
		||||
        [subs, "launch"],
 | 
			
		||||
        [stream_settings_ui, "launch"],
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    recent_topics_ui_shown = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ const reactions = mock_esm("../../static/js/reactions");
 | 
			
		||||
const search = mock_esm("../../static/js/search");
 | 
			
		||||
const settings_data = mock_esm("../../static/js/settings_data");
 | 
			
		||||
const stream_list = mock_esm("../../static/js/stream_list");
 | 
			
		||||
const subs = mock_esm("../../static/js/subs");
 | 
			
		||||
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui");
 | 
			
		||||
 | 
			
		||||
mock_esm("../../static/js/hotspots", {
 | 
			
		||||
    is_open: () => false,
 | 
			
		||||
@@ -278,9 +278,9 @@ run_test("streams", ({override}) => {
 | 
			
		||||
    settings_data.user_can_create_streams = () => true;
 | 
			
		||||
    override(overlays, "streams_open", () => true);
 | 
			
		||||
    override(overlays, "is_active", () => true);
 | 
			
		||||
    assert_mapping("S", subs, "keyboard_sub");
 | 
			
		||||
    assert_mapping("V", subs, "view_stream");
 | 
			
		||||
    assert_mapping("n", subs, "open_create_stream");
 | 
			
		||||
    assert_mapping("S", stream_settings_ui, "keyboard_sub");
 | 
			
		||||
    assert_mapping("V", stream_settings_ui, "view_stream");
 | 
			
		||||
    assert_mapping("n", stream_settings_ui, "open_create_stream");
 | 
			
		||||
    settings_data.user_can_create_streams = () => false;
 | 
			
		||||
    assert_unmapped("n");
 | 
			
		||||
});
 | 
			
		||||
@@ -471,8 +471,8 @@ run_test("motion_keys", () => {
 | 
			
		||||
    overlays.info_overlay_open = () => false;
 | 
			
		||||
 | 
			
		||||
    overlays.streams_open = () => true;
 | 
			
		||||
    assert_mapping("up_arrow", subs, "switch_rows");
 | 
			
		||||
    assert_mapping("down_arrow", subs, "switch_rows");
 | 
			
		||||
    assert_mapping("up_arrow", stream_settings_ui, "switch_rows");
 | 
			
		||||
    assert_mapping("down_arrow", stream_settings_ui, "switch_rows");
 | 
			
		||||
    overlays.streams_open = () => false;
 | 
			
		||||
 | 
			
		||||
    overlays.lightbox_open = () => true;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ const message_util = mock_esm("../../static/js/message_util");
 | 
			
		||||
const stream_color = mock_esm("../../static/js/stream_color");
 | 
			
		||||
const stream_list = mock_esm("../../static/js/stream_list");
 | 
			
		||||
const stream_muting = mock_esm("../../static/js/stream_muting");
 | 
			
		||||
const subs = mock_esm("../../static/js/subs", {
 | 
			
		||||
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui", {
 | 
			
		||||
    update_settings_for_subscribed: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -166,7 +166,7 @@ test("update_property", ({override}) => {
 | 
			
		||||
    // Test name change
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "update_stream_name", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "update_stream_name", stub.f);
 | 
			
		||||
        stream_events.update_property(stream_id, "name", "the frontend");
 | 
			
		||||
        assert.equal(stub.num_calls, 1);
 | 
			
		||||
        const args = stub.get_args("sub", "val");
 | 
			
		||||
@@ -177,7 +177,7 @@ test("update_property", ({override}) => {
 | 
			
		||||
    // Test description change
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "update_stream_description", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "update_stream_description", stub.f);
 | 
			
		||||
        stream_events.update_property(stream_id, "description", "we write code", {
 | 
			
		||||
            rendered_description: "we write code",
 | 
			
		||||
        });
 | 
			
		||||
@@ -202,7 +202,7 @@ test("update_property", ({override}) => {
 | 
			
		||||
    // Test stream privacy change event
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "update_stream_privacy", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "update_stream_privacy", stub.f);
 | 
			
		||||
        stream_events.update_property(stream_id, "invite_only", true, {
 | 
			
		||||
            history_public_to_subscribers: true,
 | 
			
		||||
        });
 | 
			
		||||
@@ -218,7 +218,7 @@ test("update_property", ({override}) => {
 | 
			
		||||
    // Test stream stream_post_policy change event
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "update_stream_post_policy", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "update_stream_post_policy", stub.f);
 | 
			
		||||
        stream_events.update_property(
 | 
			
		||||
            stream_id,
 | 
			
		||||
            "stream_post_policy",
 | 
			
		||||
@@ -233,7 +233,7 @@ test("update_property", ({override}) => {
 | 
			
		||||
    // Test stream message_retention_days change event
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "update_message_retention_setting", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "update_message_retention_setting", stub.f);
 | 
			
		||||
        stream_events.update_property(stream_id, "message_retention_days", 20);
 | 
			
		||||
        assert.equal(stub.num_calls, 1);
 | 
			
		||||
        const args = stub.get_args("sub", "val");
 | 
			
		||||
@@ -316,7 +316,7 @@ test("marked_subscribed (color)", ({override}) => {
 | 
			
		||||
    // narrow state is undefined
 | 
			
		||||
    {
 | 
			
		||||
        const stub = make_stub();
 | 
			
		||||
        override(subs, "set_color", stub.f);
 | 
			
		||||
        override(stream_settings_ui, "set_color", stub.f);
 | 
			
		||||
        blueslip.expect("warn", "Frontend needed to pick a color in mark_subscribed");
 | 
			
		||||
        stream_events.mark_subscribed(sub, [], undefined);
 | 
			
		||||
        assert.equal(stub.num_calls, 1);
 | 
			
		||||
@@ -338,7 +338,7 @@ test("marked_subscribed (emails)", ({override}) => {
 | 
			
		||||
    override(stream_list, "add_sidebar_row", noop);
 | 
			
		||||
 | 
			
		||||
    const subs_stub = make_stub();
 | 
			
		||||
    override(subs, "update_settings_for_subscribed", subs_stub.f);
 | 
			
		||||
    override(stream_settings_ui, "update_settings_for_subscribed", subs_stub.f);
 | 
			
		||||
 | 
			
		||||
    assert.ok(!stream_data.is_subscribed(sub.name));
 | 
			
		||||
 | 
			
		||||
@@ -358,7 +358,7 @@ test("mark_unsubscribed (update_settings_for_unsubscribed)", ({override}) => {
 | 
			
		||||
 | 
			
		||||
    const stub = make_stub();
 | 
			
		||||
 | 
			
		||||
    override(subs, "update_settings_for_unsubscribed", stub.f);
 | 
			
		||||
    override(stream_settings_ui, "update_settings_for_unsubscribed", stub.f);
 | 
			
		||||
    override(stream_list, "remove_sidebar_row", noop);
 | 
			
		||||
    override(stream_data, "unsubscribe_myself", noop);
 | 
			
		||||
 | 
			
		||||
@@ -376,7 +376,7 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {
 | 
			
		||||
    const message_view_header_stub = make_stub();
 | 
			
		||||
    override(message_view_header, "render_title_area", message_view_header_stub.f);
 | 
			
		||||
    override(stream_data, "unsubscribe_myself", noop);
 | 
			
		||||
    override(subs, "update_settings_for_unsubscribed", noop);
 | 
			
		||||
    override(stream_settings_ui, "update_settings_for_unsubscribed", noop);
 | 
			
		||||
    override(message_lists.current, "update_trailing_bookend", noop);
 | 
			
		||||
    override(stream_list, "remove_sidebar_row", noop);
 | 
			
		||||
 | 
			
		||||
@@ -390,7 +390,7 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {
 | 
			
		||||
test("remove_deactivated_user_from_all_streams", () => {
 | 
			
		||||
    stream_data.add_sub(dev_help);
 | 
			
		||||
    const subs_stub = make_stub();
 | 
			
		||||
    subs.update_subscribers_ui = subs_stub.f;
 | 
			
		||||
    stream_settings_ui.update_subscribers_ui = subs_stub.f;
 | 
			
		||||
 | 
			
		||||
    // assert starting state
 | 
			
		||||
    assert.ok(!stream_data.is_user_subscribed(dev_help.stream_id, george.user_id));
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ mock_esm("../../static/js/hash_util", {
 | 
			
		||||
set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const stream_data = zrequire("stream_data");
 | 
			
		||||
const subs = zrequire("subs");
 | 
			
		||||
const stream_settings_ui = zrequire("stream_settings_ui");
 | 
			
		||||
 | 
			
		||||
run_test("redraw_left_panel", ({mock_template}) => {
 | 
			
		||||
    // set-up sub rows stubs
 | 
			
		||||
@@ -88,7 +88,7 @@ run_test("redraw_left_panel", ({mock_template}) => {
 | 
			
		||||
        populated_subs = data.subscriptions;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    subs.render_left_panel_superset();
 | 
			
		||||
    stream_settings_ui.render_left_panel_superset();
 | 
			
		||||
 | 
			
		||||
    const sub_stubs = [];
 | 
			
		||||
 | 
			
		||||
@@ -115,7 +115,7 @@ run_test("redraw_left_panel", ({mock_template}) => {
 | 
			
		||||
    assert.ok(!denmark_row.hasClass("active"));
 | 
			
		||||
 | 
			
		||||
    function test_filter(params, expected_streams) {
 | 
			
		||||
        const stream_ids = subs.redraw_left_panel(params);
 | 
			
		||||
        const stream_ids = stream_settings_ui.redraw_left_panel(params);
 | 
			
		||||
        assert.deepEqual(
 | 
			
		||||
            stream_ids,
 | 
			
		||||
            expected_streams.map((sub) => sub.stream_id),
 | 
			
		||||
@@ -34,8 +34,8 @@ import * as server_events from "./server_events";
 | 
			
		||||
import * as settings_data from "./settings_data";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_edit from "./stream_edit";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as sub_store from "./sub_store";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as transmit from "./transmit";
 | 
			
		||||
import * as ui_report from "./ui_report";
 | 
			
		||||
import * as upload from "./upload";
 | 
			
		||||
@@ -653,7 +653,7 @@ export function initialize() {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        const sub = stream_data.get_sub(stream_name);
 | 
			
		||||
        subs.sub_or_unsub(sub);
 | 
			
		||||
        stream_settings_ui.sub_or_unsub(sub);
 | 
			
		||||
        $("#compose-send-status").hide();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import * as search from "./search";
 | 
			
		||||
import * as settings from "./settings";
 | 
			
		||||
import * as settings_panel_menu from "./settings_panel_menu";
 | 
			
		||||
import * as settings_toggle from "./settings_toggle";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as top_left_corner from "./top_left_corner";
 | 
			
		||||
import * as ui_util from "./ui_util";
 | 
			
		||||
 | 
			
		||||
@@ -205,7 +205,7 @@ function do_hashchange_overlay(old_hash) {
 | 
			
		||||
    // the new overlay.
 | 
			
		||||
    if (coming_from_overlay && base === old_base) {
 | 
			
		||||
        if (base === "streams") {
 | 
			
		||||
            subs.change_state(section);
 | 
			
		||||
            stream_settings_ui.change_state(section);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -266,7 +266,7 @@ function do_hashchange_overlay(old_hash) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (base === "streams") {
 | 
			
		||||
        subs.launch(section);
 | 
			
		||||
        stream_settings_ui.launch(section);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ import * as search from "./search";
 | 
			
		||||
import * as settings_data from "./settings_data";
 | 
			
		||||
import * as stream_list from "./stream_list";
 | 
			
		||||
import * as stream_popover from "./stream_popover";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as topic_zoom from "./topic_zoom";
 | 
			
		||||
import * as ui from "./ui";
 | 
			
		||||
 | 
			
		||||
@@ -582,7 +582,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (event_name === "narrow_by_topic" && overlays.streams_open()) {
 | 
			
		||||
            subs.keyboard_sub();
 | 
			
		||||
            stream_settings_ui.keyboard_sub();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (event_name === "show_lightbox" && overlays.lightbox_open()) {
 | 
			
		||||
@@ -621,7 +621,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((event_name === "up_arrow" || event_name === "down_arrow") && overlays.streams_open()) {
 | 
			
		||||
        return subs.switch_rows(event_name);
 | 
			
		||||
        return stream_settings_ui.switch_rows(event_name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (event_name === "up_arrow" && list_util.inside_list(e)) {
 | 
			
		||||
@@ -703,7 +703,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
            lightbox.prev();
 | 
			
		||||
            return true;
 | 
			
		||||
        } else if (overlays.streams_open()) {
 | 
			
		||||
            subs.toggle_view(event_name);
 | 
			
		||||
            stream_settings_ui.toggle_view(event_name);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -716,7 +716,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
            lightbox.next();
 | 
			
		||||
            return true;
 | 
			
		||||
        } else if (overlays.streams_open()) {
 | 
			
		||||
            subs.toggle_view(event_name);
 | 
			
		||||
            stream_settings_ui.toggle_view(event_name);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -724,7 +724,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
    // Prevent navigation in the background when the overlays are active.
 | 
			
		||||
    if (overlays.is_active()) {
 | 
			
		||||
        if (event_name === "view_selected_stream" && overlays.streams_open()) {
 | 
			
		||||
            subs.view_stream();
 | 
			
		||||
            stream_settings_ui.view_stream();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        if (
 | 
			
		||||
@@ -732,7 +732,7 @@ export function process_hotkey(e, hotkey) {
 | 
			
		||||
            overlays.streams_open() &&
 | 
			
		||||
            settings_data.user_can_create_streams()
 | 
			
		||||
        ) {
 | 
			
		||||
            subs.open_create_stream();
 | 
			
		||||
            stream_settings_ui.open_create_stream();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -155,7 +155,7 @@ function populate_group_from_message_container(group, message_container) {
 | 
			
		||||
            // Hack to handle unusual cases like the tutorial where
 | 
			
		||||
            // the streams used don't actually exist in the subs
 | 
			
		||||
            // module.  Ideally, we'd clean this up by making the
 | 
			
		||||
            // tutorial populate subs.js "properly".
 | 
			
		||||
            // tutorial populate stream_settings_ui.js "properly".
 | 
			
		||||
            group.stream_id = -1;
 | 
			
		||||
        } else {
 | 
			
		||||
            group.stream_id = sub.stream_id;
 | 
			
		||||
 
 | 
			
		||||
@@ -54,10 +54,10 @@ import * as starred_messages from "./starred_messages";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_events from "./stream_events";
 | 
			
		||||
import * as stream_list from "./stream_list";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as stream_topic_history from "./stream_topic_history";
 | 
			
		||||
import * as sub_store from "./sub_store";
 | 
			
		||||
import * as submessage from "./submessage";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as typing_events from "./typing_events";
 | 
			
		||||
import * as unread_ops from "./unread_ops";
 | 
			
		||||
import * as user_events from "./user_events";
 | 
			
		||||
@@ -398,7 +398,7 @@ export function dispatch_normal_event(event) {
 | 
			
		||||
        case "stream":
 | 
			
		||||
            switch (event.op) {
 | 
			
		||||
                case "update":
 | 
			
		||||
                    // Legacy: Stream properties are still managed by subs.js on the client side.
 | 
			
		||||
                    // Legacy: Stream properties are still managed by stream_settings_ui.js on the client side.
 | 
			
		||||
                    stream_events.update_property(event.stream_id, event.property, event.value, {
 | 
			
		||||
                        rendered_description: event.rendered_description,
 | 
			
		||||
                        history_public_to_subscribers: event.history_public_to_subscribers,
 | 
			
		||||
@@ -411,7 +411,7 @@ export function dispatch_normal_event(event) {
 | 
			
		||||
                    for (const stream of event.streams) {
 | 
			
		||||
                        const sub = sub_store.get(stream.stream_id);
 | 
			
		||||
                        if (overlays.streams_open()) {
 | 
			
		||||
                            subs.add_sub_to_table(sub);
 | 
			
		||||
                            stream_settings_ui.add_sub_to_table(sub);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
@@ -421,7 +421,7 @@ export function dispatch_normal_event(event) {
 | 
			
		||||
                        const is_narrowed_to_stream = narrow_state.is_for_stream_id(
 | 
			
		||||
                            stream.stream_id,
 | 
			
		||||
                        );
 | 
			
		||||
                        subs.remove_stream(stream.stream_id);
 | 
			
		||||
                        stream_settings_ui.remove_stream(stream.stream_id);
 | 
			
		||||
                        stream_data.delete_sub(stream.stream_id);
 | 
			
		||||
                        if (was_subscribed) {
 | 
			
		||||
                            stream_list.remove_sidebar_row(stream.stream_id);
 | 
			
		||||
@@ -485,7 +485,7 @@ export function dispatch_normal_event(event) {
 | 
			
		||||
 | 
			
		||||
                    for (const stream_id of stream_ids) {
 | 
			
		||||
                        const sub = sub_store.get(stream_id);
 | 
			
		||||
                        subs.update_subscribers_ui(sub);
 | 
			
		||||
                        stream_settings_ui.update_subscribers_ui(sub);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    compose_fade.update_faded_users();
 | 
			
		||||
@@ -499,7 +499,7 @@ export function dispatch_normal_event(event) {
 | 
			
		||||
 | 
			
		||||
                    for (const stream_id of stream_ids) {
 | 
			
		||||
                        const sub = sub_store.get(stream_id);
 | 
			
		||||
                        subs.update_subscribers_ui(sub);
 | 
			
		||||
                        stream_settings_ui.update_subscribers_ui(sub);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    compose_fade.update_faded_users();
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ import $ from "jquery";
 | 
			
		||||
import * as color_class from "./color_class";
 | 
			
		||||
import {$t} from "./i18n";
 | 
			
		||||
import * as message_view_header from "./message_view_header";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
 | 
			
		||||
function update_table_stream_color(table, stream_name, color) {
 | 
			
		||||
    // This is ugly, but temporary, as the new design will make it
 | 
			
		||||
@@ -102,7 +102,7 @@ export function update_stream_color(sub, color, {update_historical = false} = {}
 | 
			
		||||
function picker_do_change_color(color) {
 | 
			
		||||
    const stream_id = Number.parseInt($(this).attr("stream_id"), 10);
 | 
			
		||||
    const hex_color = color.toHexString();
 | 
			
		||||
    subs.set_color(stream_id, hex_color);
 | 
			
		||||
    stream_settings_ui.set_color(stream_id, hex_color);
 | 
			
		||||
}
 | 
			
		||||
subscriptions_table_colorpicker_options.change = picker_do_change_color;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import * as peer_data from "./peer_data";
 | 
			
		||||
import * as people from "./people";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_settings_data from "./stream_settings_data";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as ui_report from "./ui_report";
 | 
			
		||||
 | 
			
		||||
let created_stream;
 | 
			
		||||
@@ -260,7 +260,7 @@ function create_stream() {
 | 
			
		||||
export function new_stream_clicked(stream_name) {
 | 
			
		||||
    // this changes the tab switcher (settings/preview) which isn't necessary
 | 
			
		||||
    // to a add new stream title.
 | 
			
		||||
    subs.show_subs_pane.create_stream();
 | 
			
		||||
    stream_settings_ui.show_subs_pane.create_stream();
 | 
			
		||||
    $(".stream-row.active").removeClass("active");
 | 
			
		||||
 | 
			
		||||
    if (stream_name !== "") {
 | 
			
		||||
 
 | 
			
		||||
@@ -31,9 +31,9 @@ import * as stream_color from "./stream_color";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_pill from "./stream_pill";
 | 
			
		||||
import * as stream_settings_data from "./stream_settings_data";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as stream_ui_updates from "./stream_ui_updates";
 | 
			
		||||
import * as sub_store from "./sub_store";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as ui from "./ui";
 | 
			
		||||
import * as ui_report from "./ui_report";
 | 
			
		||||
import * as user_group_pill from "./user_group_pill";
 | 
			
		||||
@@ -183,16 +183,16 @@ export function open_edit_panel_for_row(stream_row) {
 | 
			
		||||
    const sub = get_sub_for_target(stream_row);
 | 
			
		||||
 | 
			
		||||
    $(".stream-row.active").removeClass("active");
 | 
			
		||||
    subs.show_subs_pane.settings(sub.name);
 | 
			
		||||
    stream_settings_ui.show_subs_pane.settings(sub.name);
 | 
			
		||||
    $(stream_row).addClass("active");
 | 
			
		||||
    setup_subscriptions_stream_hash(sub);
 | 
			
		||||
    setup_stream_settings(stream_row);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function open_edit_panel_empty() {
 | 
			
		||||
    const tab_key = $(subs.get_active_data().tabs[0]).attr("data-tab-key");
 | 
			
		||||
    const tab_key = $(stream_settings_ui.get_active_data().tabs[0]).attr("data-tab-key");
 | 
			
		||||
    $(".stream-row.active").removeClass("active");
 | 
			
		||||
    subs.show_subs_pane.nothing_selected();
 | 
			
		||||
    stream_settings_ui.show_subs_pane.nothing_selected();
 | 
			
		||||
    setup_subscriptions_tab_hash(tab_key);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -575,7 +575,7 @@ function stream_is_muted_changed(e) {
 | 
			
		||||
    const sub_settings = settings_for_sub(sub);
 | 
			
		||||
    const notification_checkboxes = sub_settings.find(".sub_notification_setting");
 | 
			
		||||
 | 
			
		||||
    subs.set_muted(
 | 
			
		||||
    stream_settings_ui.set_muted(
 | 
			
		||||
        sub,
 | 
			
		||||
        e.target.checked,
 | 
			
		||||
        `#stream_change_property_status${CSS.escape(sub.stream_id)}`,
 | 
			
		||||
@@ -727,7 +727,7 @@ export function initialize() {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        subs.sub_or_unsub(sub);
 | 
			
		||||
        stream_settings_ui.sub_or_unsub(sub);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    $("#subscriptions_table").on("click", ".change-stream-privacy", (e) => {
 | 
			
		||||
@@ -917,7 +917,7 @@ export function initialize() {
 | 
			
		||||
        const stream_row = $(
 | 
			
		||||
            `#subscriptions_table div.stream-row[data-stream-id='${CSS.escape(sub.stream_id)}']`,
 | 
			
		||||
        );
 | 
			
		||||
        subs.sub_or_unsub(sub, false, stream_row);
 | 
			
		||||
        stream_settings_ui.sub_or_unsub(sub, false, stream_row);
 | 
			
		||||
 | 
			
		||||
        if (!sub.subscribed) {
 | 
			
		||||
            open_edit_panel_for_row(stream_row);
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,8 @@ import * as stream_color from "./stream_color";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_list from "./stream_list";
 | 
			
		||||
import * as stream_muting from "./stream_muting";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as sub_store from "./sub_store";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
 | 
			
		||||
// In theory, this function should apply the account-level defaults,
 | 
			
		||||
// however, they are only called after a manual override, so
 | 
			
		||||
@@ -57,10 +57,14 @@ export function update_property(stream_id, property, value, other_values) {
 | 
			
		||||
            settings_notifications.update_page();
 | 
			
		||||
            break;
 | 
			
		||||
        case "name":
 | 
			
		||||
            subs.update_stream_name(sub, value);
 | 
			
		||||
            stream_settings_ui.update_stream_name(sub, value);
 | 
			
		||||
            break;
 | 
			
		||||
        case "description":
 | 
			
		||||
            subs.update_stream_description(sub, value, other_values.rendered_description);
 | 
			
		||||
            stream_settings_ui.update_stream_description(
 | 
			
		||||
                sub,
 | 
			
		||||
                value,
 | 
			
		||||
                other_values.rendered_description,
 | 
			
		||||
            );
 | 
			
		||||
            break;
 | 
			
		||||
        case "email_address":
 | 
			
		||||
            sub.email_address = value;
 | 
			
		||||
@@ -70,16 +74,16 @@ export function update_property(stream_id, property, value, other_values) {
 | 
			
		||||
            stream_list.refresh_pinned_or_unpinned_stream(sub);
 | 
			
		||||
            break;
 | 
			
		||||
        case "invite_only":
 | 
			
		||||
            subs.update_stream_privacy(sub, {
 | 
			
		||||
            stream_settings_ui.update_stream_privacy(sub, {
 | 
			
		||||
                invite_only: value,
 | 
			
		||||
                history_public_to_subscribers: other_values.history_public_to_subscribers,
 | 
			
		||||
            });
 | 
			
		||||
            break;
 | 
			
		||||
        case "stream_post_policy":
 | 
			
		||||
            subs.update_stream_post_policy(sub, value);
 | 
			
		||||
            stream_settings_ui.update_stream_post_policy(sub, value);
 | 
			
		||||
            break;
 | 
			
		||||
        case "message_retention_days":
 | 
			
		||||
            subs.update_message_retention_setting(sub, value);
 | 
			
		||||
            stream_settings_ui.update_message_retention_setting(sub, value);
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            blueslip.warn("Unexpected subscription property type", {
 | 
			
		||||
@@ -112,7 +116,7 @@ export function mark_subscribed(sub, subscribers, color) {
 | 
			
		||||
        // needed.
 | 
			
		||||
        blueslip.warn("Frontend needed to pick a color in mark_subscribed");
 | 
			
		||||
        color = color_data.pick_color();
 | 
			
		||||
        subs.set_color(sub.stream_id, color);
 | 
			
		||||
        stream_settings_ui.set_color(sub.stream_id, color);
 | 
			
		||||
    }
 | 
			
		||||
    stream_data.subscribe_myself(sub);
 | 
			
		||||
    if (subscribers) {
 | 
			
		||||
@@ -120,7 +124,7 @@ export function mark_subscribed(sub, subscribers, color) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (overlays.streams_open()) {
 | 
			
		||||
        subs.update_settings_for_subscribed(sub);
 | 
			
		||||
        stream_settings_ui.update_settings_for_subscribed(sub);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // update navbar if necessary
 | 
			
		||||
@@ -144,7 +148,7 @@ export function mark_unsubscribed(sub) {
 | 
			
		||||
    } else if (sub.subscribed) {
 | 
			
		||||
        stream_data.unsubscribe_myself(sub);
 | 
			
		||||
        if (overlays.streams_open()) {
 | 
			
		||||
            subs.update_settings_for_unsubscribed(sub);
 | 
			
		||||
            stream_settings_ui.update_settings_for_unsubscribed(sub);
 | 
			
		||||
        }
 | 
			
		||||
        // update navbar if necessary
 | 
			
		||||
        message_view_header.maybe_rerender_title_area_for_stream(sub);
 | 
			
		||||
@@ -166,7 +170,7 @@ export function remove_deactivated_user_from_all_streams(user_id) {
 | 
			
		||||
    for (const sub of all_subs) {
 | 
			
		||||
        if (stream_data.is_user_subscribed(sub.stream_id, user_id)) {
 | 
			
		||||
            peer_data.remove_subscriber(sub.stream_id, user_id);
 | 
			
		||||
            subs.update_subscribers_ui(sub);
 | 
			
		||||
            stream_settings_ui.update_subscribers_ui(sub);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,8 @@ import * as starred_messages_ui from "./starred_messages_ui";
 | 
			
		||||
import * as stream_bar from "./stream_bar";
 | 
			
		||||
import * as stream_color from "./stream_color";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as sub_store from "./sub_store";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as unread_ops from "./unread_ops";
 | 
			
		||||
 | 
			
		||||
// We handle stream popovers and topic popovers in this
 | 
			
		||||
@@ -461,7 +461,7 @@ export function register_stream_handlers() {
 | 
			
		||||
    $("body").on("click", ".pin_to_top", (e) => {
 | 
			
		||||
        const sub = stream_popover_sub(e);
 | 
			
		||||
        hide_stream_popover();
 | 
			
		||||
        subs.toggle_pin_to_top_stream(sub);
 | 
			
		||||
        stream_settings_ui.toggle_pin_to_top_stream(sub);
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@@ -518,7 +518,7 @@ export function register_stream_handlers() {
 | 
			
		||||
    $("body").on("click", ".toggle_stream_muted", (e) => {
 | 
			
		||||
        const sub = stream_popover_sub(e);
 | 
			
		||||
        hide_stream_popover();
 | 
			
		||||
        subs.set_muted(sub, !sub.is_muted);
 | 
			
		||||
        stream_settings_ui.set_muted(sub, !sub.is_muted);
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@@ -542,7 +542,7 @@ export function register_stream_handlers() {
 | 
			
		||||
        $(this).closest(".popover").fadeOut(500).delay(500).remove();
 | 
			
		||||
 | 
			
		||||
        const sub = stream_popover_sub(e);
 | 
			
		||||
        subs.sub_or_unsub(sub, true);
 | 
			
		||||
        stream_settings_ui.sub_or_unsub(sub, true);
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ import {page_params} from "./page_params";
 | 
			
		||||
import * as peer_data from "./peer_data";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_edit from "./stream_edit";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
 | 
			
		||||
export function initialize_disable_btn_hint_popover(
 | 
			
		||||
    btn_wrapper,
 | 
			
		||||
@@ -41,7 +41,7 @@ export function initialize_disable_btn_hint_popover(
 | 
			
		||||
 | 
			
		||||
export function initialize_cant_subscribe_popover(sub) {
 | 
			
		||||
    const button_wrapper = stream_edit.settings_for_sub(sub).find(".sub_unsub_button_wrapper");
 | 
			
		||||
    const settings_button = subs.settings_button_for_sub(sub);
 | 
			
		||||
    const settings_button = stream_settings_ui.settings_button_for_sub(sub);
 | 
			
		||||
    initialize_disable_btn_hint_popover(
 | 
			
		||||
        button_wrapper,
 | 
			
		||||
        settings_button,
 | 
			
		||||
@@ -72,7 +72,7 @@ export function update_toggler_for_sub(sub) {
 | 
			
		||||
 | 
			
		||||
export function update_settings_button_for_sub(sub) {
 | 
			
		||||
    // This is for the Subscribe/Unsubscribe button in the right panel.
 | 
			
		||||
    const settings_button = subs.settings_button_for_sub(sub);
 | 
			
		||||
    const settings_button = stream_settings_ui.settings_button_for_sub(sub);
 | 
			
		||||
    if (sub.subscribed) {
 | 
			
		||||
        settings_button.text($t({defaultMessage: "Unsubscribe"})).removeClass("unsubscribed");
 | 
			
		||||
    } else {
 | 
			
		||||
@@ -140,8 +140,8 @@ export function update_stream_row_in_settings_tab(sub) {
 | 
			
		||||
    // If user is subscribed to stream, it will show sub row under
 | 
			
		||||
    // "Subscribed" tab, otherwise if stream is not public hide
 | 
			
		||||
    // stream row under tab.
 | 
			
		||||
    if (subs.is_subscribed_stream_tab_active()) {
 | 
			
		||||
        const sub_row = subs.row_for_stream_id(sub.stream_id);
 | 
			
		||||
    if (stream_settings_ui.is_subscribed_stream_tab_active()) {
 | 
			
		||||
        const sub_row = stream_settings_ui.row_for_stream_id(sub.stream_id);
 | 
			
		||||
        if (sub.subscribed) {
 | 
			
		||||
            sub_row.removeClass("notdisplayed");
 | 
			
		||||
        } else if (sub.invite_only || page_params.is_guest) {
 | 
			
		||||
 
 | 
			
		||||
@@ -76,7 +76,7 @@ import * as stream_bar from "./stream_bar";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_edit from "./stream_edit";
 | 
			
		||||
import * as stream_list from "./stream_list";
 | 
			
		||||
import * as subs from "./subs";
 | 
			
		||||
import * as stream_settings_ui from "./stream_settings_ui";
 | 
			
		||||
import * as timerender from "./timerender";
 | 
			
		||||
import * as tippyjs from "./tippyjs";
 | 
			
		||||
import * as topic_list from "./topic_list";
 | 
			
		||||
@@ -522,7 +522,7 @@ export function initialize_everything() {
 | 
			
		||||
    pm_conversations.recent.initialize(pm_conversations_params);
 | 
			
		||||
    muted_topics.initialize();
 | 
			
		||||
    muted_users.initialize();
 | 
			
		||||
    subs.initialize();
 | 
			
		||||
    stream_settings_ui.initialize();
 | 
			
		||||
    stream_list.initialize();
 | 
			
		||||
    condense.initialize();
 | 
			
		||||
    spoilers.initialize();
 | 
			
		||||
 
 | 
			
		||||
@@ -154,7 +154,7 @@ EXEMPT_FILES = {
 | 
			
		||||
    "static/js/stream_popover.js",
 | 
			
		||||
    "static/js/stream_ui_updates.js",
 | 
			
		||||
    "static/js/submessage.js",
 | 
			
		||||
    "static/js/subs.js",
 | 
			
		||||
    "static/js/stream_settings_ui.js",
 | 
			
		||||
    "static/js/message_view_header.js",
 | 
			
		||||
    "static/js/timerender.js",
 | 
			
		||||
    "static/js/tippyjs.js",
 | 
			
		||||
 
 | 
			
		||||
@@ -3478,7 +3478,7 @@ def internal_send_huddle_message(
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def pick_color(user_profile: UserProfile, used_colors: Set[str]) -> str:
 | 
			
		||||
    # These colors are shared with the palette in subs.js.
 | 
			
		||||
    # These colors are shared with the palette in stream_settings_ui.js.
 | 
			
		||||
    available_colors = [s for s in STREAM_ASSIGNMENT_COLORS if s not in used_colors]
 | 
			
		||||
 | 
			
		||||
    if available_colors:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user