Add VoIP user mapper

The accompanying element-web PR with the config documentation should
explain what this is & why. Internally, this breaks the assumption
that call.roomId is the room that the call appears in for the user.
call.roomId may now be a 'virtual' room while the react SDK actually
displays it in a different room. React SDK always stores the calls
under the user-facing rooms, and provides a function to get the
user-facing room for a given call.
This commit is contained in:
David Baker 2021-01-21 19:20:35 +00:00
parent 604b9378ce
commit 0a90c982c7
8 changed files with 173 additions and 32 deletions

View file

@ -16,6 +16,7 @@
import {Room} from "matrix-js-sdk/src/models/room";
import { RoomListCustomisations } from "../../../customisations/RoomList";
import { isVirtualRoom, voipUserMapperEnabled } from "../../../VoipUserMapper";
export class VisibilityProvider {
private static internalInstance: VisibilityProvider;
@ -31,18 +32,13 @@ export class VisibilityProvider {
}
public isRoomVisible(room: Room): boolean {
/* eslint-disable prefer-const */
let isVisible = true; // Returned at the end of this function
let forced = false; // When true, this function won't bother calling the customisation points
/* eslint-enable prefer-const */
// ------
// TODO: The `if` statements to control visibility of custom room types
// would go here. The remainder of this function assumes that the statements
// will be here.
//
// When removing this comment block, please remove the lint disable lines in the area.
// ------
if (voipUserMapperEnabled() && isVirtualRoom(room.roomId)) {
isVisible = false;
forced = true;
}
const isVisibleFn = RoomListCustomisations.isRoomVisible;
if (!forced && isVisibleFn) {