mirror of https://github.com/zulip/zulip.git
stream_data: Get is_invite_only by stream_id instead of name.
This commit is contained in:
parent
8e33b7a3a7
commit
45af8a9406
|
@ -190,7 +190,9 @@ function populate_group_from_message_container(group, message_container) {
|
||||||
const color = stream_data.get_color(message_container.msg.stream_id);
|
const color = stream_data.get_color(message_container.msg.stream_id);
|
||||||
group.recipient_bar_color = stream_color.get_recipient_bar_color(color);
|
group.recipient_bar_color = stream_color.get_recipient_bar_color(color);
|
||||||
group.stream_privacy_icon_color = stream_color.get_stream_privacy_icon_color(color);
|
group.stream_privacy_icon_color = stream_color.get_stream_privacy_icon_color(color);
|
||||||
group.invite_only = stream_data.is_invite_only_by_stream_name(message_container.msg.stream);
|
group.invite_only = stream_data.is_invite_only_by_stream_id(
|
||||||
|
message_container.msg.stream_id,
|
||||||
|
);
|
||||||
group.is_web_public = stream_data.is_web_public(message_container.msg.stream_id);
|
group.is_web_public = stream_data.is_web_public(message_container.msg.stream_id);
|
||||||
group.topic = message_container.msg.topic;
|
group.topic = message_container.msg.topic;
|
||||||
group.match_topic = util.get_match_topic(message_container.msg);
|
group.match_topic = util.get_match_topic(message_container.msg);
|
||||||
|
|
|
@ -679,8 +679,8 @@ export function is_web_public(stream_id: number): boolean {
|
||||||
return sub ? sub.is_web_public : false;
|
return sub ? sub.is_web_public : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_invite_only_by_stream_name(stream_name: string): boolean {
|
export function is_invite_only_by_stream_id(stream_id: number): boolean {
|
||||||
const sub = get_sub(stream_name);
|
const sub = get_sub_by_id(stream_id);
|
||||||
if (sub === undefined) {
|
if (sub === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,9 @@ test("basics", () => {
|
||||||
assert.ok(!stream_data.is_web_public_by_stream_name(social.name));
|
assert.ok(!stream_data.is_web_public_by_stream_name(social.name));
|
||||||
assert.ok(!stream_data.is_web_public_by_stream_name("unknown"));
|
assert.ok(!stream_data.is_web_public_by_stream_name("unknown"));
|
||||||
|
|
||||||
assert.ok(stream_data.is_invite_only_by_stream_name("social"));
|
assert.ok(stream_data.is_invite_only_by_stream_id(social.stream_id));
|
||||||
assert.ok(!stream_data.is_invite_only_by_stream_name("unknown"));
|
// Unknown stream id
|
||||||
|
assert.ok(!stream_data.is_invite_only_by_stream_id(1000));
|
||||||
|
|
||||||
assert.equal(stream_data.get_color(social.stream_id), "red");
|
assert.equal(stream_data.get_color(social.stream_id), "red");
|
||||||
assert.equal(stream_data.get_color(""), "#c2c2c2");
|
assert.equal(stream_data.get_color(""), "#c2c2c2");
|
||||||
|
|
Loading…
Reference in New Issue