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:
Steve Howell 2021-01-13 21:13:59 +00:00 committed by Tim Abbott
parent 355f44ef13
commit 2382fa7a19
3 changed files with 3 additions and 6 deletions

View File

@ -1006,7 +1006,7 @@ run_test("is_subscriber_subset", () => {
];
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]);
}
});

View File

@ -981,7 +981,7 @@ exports.warn_if_private_stream_is_linked = function (linked_stream) {
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
// a subset of linked_stream's subscribers list, because
// everyone will be subscribed to the linked stream and so

View File

@ -24,10 +24,7 @@ export function maybe_clear_subscribers(stream_id) {
}
}
export function is_subscriber_subset(sub1, sub2) {
const stream_id1 = sub1.stream_id;
const stream_id2 = sub2.stream_id;
export function is_subscriber_subset(stream_id1, stream_id2) {
const sub1_set = stream_subscribers.get(stream_id1);
const sub2_set = stream_subscribers.get(stream_id2);