Don't request video for invisible group call participants

This commit is contained in:
Evan Hahn 2021-12-06 17:06:13 -06:00 committed by GitHub
parent b4b65c4f00
commit 01549b11d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 171 additions and 16 deletions

22
ts/util/setUtil.ts Normal file
View file

@ -0,0 +1,22 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
const add = <T>(set: Readonly<Set<T>>, item: T): Set<T> =>
new Set(set).add(item);
export const remove = <T>(
set: Readonly<Set<T>>,
...items: ReadonlyArray<T>
): Set<T> => {
const clone = new Set(set);
for (const item of items) {
clone.delete(item);
}
return clone;
};
export const toggle = <T>(
set: Readonly<Set<T>>,
item: Readonly<T>,
shouldInclude: boolean
): Set<T> => (shouldInclude ? add : remove)(set, item);