mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
stream_data: Track web public streams in current org.
This commit tracks all available web-public stream_ids in org.
This commit is contained in:
committed by
Tim Abbott
parent
ec82c543fe
commit
b0eefb8a31
@@ -124,6 +124,7 @@ let stream_info: BinaryDict<StreamSubscription>;
|
||||
const stream_ids_by_name = new FoldDict<number>();
|
||||
const stream_ids_by_old_names = new FoldDict<number>();
|
||||
const default_stream_ids = new Set<number>();
|
||||
const realm_web_public_stream_ids = new Set<number>();
|
||||
|
||||
export function clear_subscriptions(): void {
|
||||
// This function is only used once at page load, and then
|
||||
@@ -167,6 +168,9 @@ export function add_sub(sub: StreamSubscription): void {
|
||||
// We use create_streams for new streams in live-update events.
|
||||
stream_info.set(sub.stream_id, sub);
|
||||
stream_ids_by_name.set(sub.name, sub.stream_id);
|
||||
if (sub.is_web_public) {
|
||||
realm_web_public_stream_ids.add(sub.stream_id);
|
||||
}
|
||||
sub_store.add_hydrated_sub(sub.stream_id, sub);
|
||||
}
|
||||
|
||||
@@ -326,6 +330,7 @@ export function delete_sub(stream_id: number): void {
|
||||
}
|
||||
|
||||
sub_store.delete_sub(stream_id);
|
||||
realm_web_public_stream_ids.delete(stream_id);
|
||||
stream_info.delete(stream_id);
|
||||
}
|
||||
|
||||
@@ -434,6 +439,11 @@ export function update_stream_privacy(
|
||||
sub.invite_only = values.invite_only;
|
||||
sub.history_public_to_subscribers = values.history_public_to_subscribers;
|
||||
sub.is_web_public = values.is_web_public;
|
||||
if (sub.is_web_public) {
|
||||
realm_web_public_stream_ids.add(sub.stream_id);
|
||||
} else {
|
||||
realm_web_public_stream_ids.delete(sub.stream_id);
|
||||
}
|
||||
}
|
||||
|
||||
export function update_message_retention_setting(
|
||||
@@ -1084,6 +1094,9 @@ export function create_sub_from_server_data(
|
||||
clean_up_description(sub);
|
||||
|
||||
stream_info.set(sub.stream_id, sub);
|
||||
if (sub.is_web_public) {
|
||||
realm_web_public_stream_ids.add(sub.stream_id);
|
||||
}
|
||||
stream_ids_by_name.set(sub.name, sub.stream_id);
|
||||
sub_store.add_hydrated_sub(sub.stream_id, sub);
|
||||
|
||||
|
||||
@@ -825,7 +825,7 @@ test("stream_settings", ({override}) => {
|
||||
assert.equal(sub_rows[0].history_public_to_subscribers, true);
|
||||
assert.equal(sub_rows[0].message_retention_days, 10);
|
||||
|
||||
const sub = stream_data.get_sub("a");
|
||||
let sub = stream_data.get_sub("a");
|
||||
stream_data.update_stream_privacy(sub, {
|
||||
invite_only: false,
|
||||
history_public_to_subscribers: false,
|
||||
@@ -859,6 +859,12 @@ test("stream_settings", ({override}) => {
|
||||
assert.equal(sub_rows[0].name, "c");
|
||||
assert.equal(sub_rows[1].name, "a");
|
||||
assert.equal(sub_rows.length, 2);
|
||||
|
||||
sub = stream_data.get_sub("b");
|
||||
stream_data.update_stream_privacy(sub, {
|
||||
is_web_public: true,
|
||||
});
|
||||
assert.equal(sub.is_web_public, true);
|
||||
});
|
||||
|
||||
test("default_stream_names", () => {
|
||||
@@ -1232,6 +1238,7 @@ test("create_sub", () => {
|
||||
stream_id: 102,
|
||||
name: "India",
|
||||
subscribed: true,
|
||||
is_web_public: true,
|
||||
};
|
||||
|
||||
const canada = {
|
||||
|
||||
Reference in New Issue
Block a user