mirror of https://github.com/zulip/zulip.git
refactor: Pass stream_ids to is_subscriber_subset.
After this change all peer_data functions consistently use stream_id rather than some "sub" object whose data type is complicated by all sort of fields that don't really concern how we track subscribers.
This commit is contained in:
parent
355f44ef13
commit
2382fa7a19
|
@ -1006,7 +1006,7 @@ run_test("is_subscriber_subset", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const row of matrix) {
|
for (const row of matrix) {
|
||||||
assert.equal(peer_data.is_subscriber_subset(row[0], row[1]), row[2]);
|
assert.equal(peer_data.is_subscriber_subset(row[0].stream_id, row[1].stream_id), row[2]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -981,7 +981,7 @@ exports.warn_if_private_stream_is_linked = function (linked_stream) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_data.is_subscriber_subset(compose_stream, linked_stream)) {
|
if (peer_data.is_subscriber_subset(compose_stream.stream_id, linked_stream.stream_id)) {
|
||||||
// Don't warn if subscribers list of current compose_stream is
|
// Don't warn if subscribers list of current compose_stream is
|
||||||
// a subset of linked_stream's subscribers list, because
|
// a subset of linked_stream's subscribers list, because
|
||||||
// everyone will be subscribed to the linked stream and so
|
// everyone will be subscribed to the linked stream and so
|
||||||
|
|
|
@ -24,10 +24,7 @@ export function maybe_clear_subscribers(stream_id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_subscriber_subset(sub1, sub2) {
|
export function is_subscriber_subset(stream_id1, stream_id2) {
|
||||||
const stream_id1 = sub1.stream_id;
|
|
||||||
const stream_id2 = sub2.stream_id;
|
|
||||||
|
|
||||||
const sub1_set = stream_subscribers.get(stream_id1);
|
const sub1_set = stream_subscribers.get(stream_id1);
|
||||||
const sub2_set = stream_subscribers.get(stream_id2);
|
const sub2_set = stream_subscribers.get(stream_id2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue