From 6ffdc45c0c078b67bcbc8c2622c62503f349581b Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 31 Mar 2022 00:35:34 -0400 Subject: [PATCH] =?UTF-8?q?"Voice"=20=E2=86=92=20"video"=20in=20more=20pla?= =?UTF-8?q?ces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Lifecycle.ts | 6 +- src/components/structures/RoomView.tsx | 6 +- src/components/structures/SpaceRoomView.tsx | 4 +- .../views/context_menus/RoomContextMenu.tsx | 2 +- .../views/right_panel/RoomSummaryCard.tsx | 2 +- src/components/views/rooms/RoomList.tsx | 4 +- src/components/views/rooms/RoomListHeader.tsx | 6 +- src/components/views/rooms/RoomTile.tsx | 74 +++++++++---------- src/createRoom.ts | 8 +- src/settings/Settings.tsx | 2 +- ...ceChannelStore.ts => VideoChannelStore.ts} | 50 ++++++------- ...ceChannelUtils.ts => VideoChannelUtils.ts} | 18 ++--- src/utils/WidgetUtils.ts | 4 +- test/components/views/rooms/RoomTile-test.tsx | 18 ++--- ...tore-test.ts => VideoChannelStore-test.ts} | 30 ++++---- test/test-utils/index.ts | 2 +- test/test-utils/{voice.ts => video.ts} | 14 ++-- 17 files changed, 125 insertions(+), 125 deletions(-) rename src/stores/{VoiceChannelStore.ts => VideoChannelStore.ts} (79%) rename src/utils/{VoiceChannelUtils.ts => VideoChannelUtils.ts} (72%) rename test/stores/{VoiceChannelStore-test.ts => VideoChannelStore-test.ts} (73%) rename test/test-utils/{voice.ts => video.ts} (65%) diff --git a/src/Lifecycle.ts b/src/Lifecycle.ts index 81ed7fb8d0b..a919a9c2874 100644 --- a/src/Lifecycle.ts +++ b/src/Lifecycle.ts @@ -36,7 +36,7 @@ import dis from './dispatcher/dispatcher'; import DMRoomMap from './utils/DMRoomMap'; import Modal from './Modal'; import ActiveWidgetStore from './stores/ActiveWidgetStore'; -import VoiceChannelStore from "./stores/VoiceChannelStore"; +import VideoChannelStore from "./stores/VideoChannelStore"; import PlatformPeg from "./PlatformPeg"; import { sendLoginRequest } from "./Login"; import * as StorageManager from './utils/StorageManager'; @@ -797,7 +797,7 @@ async function startMatrixClient(startSyncing = true): Promise { IntegrationManagers.sharedInstance().startWatching(); ActiveWidgetStore.instance.start(); CallHandler.instance.start(); - if (SettingsStore.getValue("feature_voice_rooms")) VoiceChannelStore.instance.start(); + if (SettingsStore.getValue("feature_video_rooms")) VideoChannelStore.instance.start(); // Start Mjolnir even though we haven't checked the feature flag yet. Starting // the thing just wastes CPU cycles, but should result in no actual functionality @@ -911,7 +911,7 @@ export function stopMatrixClient(unsetClient = true): void { UserActivity.sharedInstance().stop(); TypingStore.sharedInstance().reset(); Presence.stop(); - if (SettingsStore.getValue("feature_voice_rooms")) VoiceChannelStore.instance.stop(); + if (SettingsStore.getValue("feature_video_rooms")) VideoChannelStore.instance.stop(); ActiveWidgetStore.instance.stop(); IntegrationManagers.sharedInstance().stopWatching(); Mjolnir.sharedInstance().stop(); diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 801f625731a..ab06369406e 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -75,7 +75,7 @@ import EffectsOverlay from "../views/elements/EffectsOverlay"; import { containsEmoji } from '../../effects/utils'; import { CHAT_EFFECTS } from '../../effects'; import WidgetStore from "../../stores/WidgetStore"; -import { getVoiceChannel } from "../../utils/VoiceChannelUtils"; +import { getVideoChannel } from "../../utils/VideoChannelUtils"; import AppTile from "../views/elements/AppTile"; import { UPDATE_EVENT } from "../../stores/AsyncStore"; import Notifier from "../../Notifier"; @@ -375,7 +375,7 @@ export class RoomView extends React.Component { }; private getMainSplitContentType = (room: Room) => { - if (SettingsStore.getValue("feature_voice_rooms") && room.isCallRoom()) { + if (SettingsStore.getValue("feature_video_rooms") && room.isCallRoom()) { return MainSplitContentType.Video; } if (WidgetLayoutStore.instance.hasMaximisedWidget(room)) { @@ -2140,7 +2140,7 @@ export class RoomView extends React.Component { ; break; case MainSplitContentType.Video: { - const app = getVoiceChannel(this.state.room.roomId); + const app = getVideoChannel(this.state.room.roomId); if (!app) break; mainSplitContentClassName = "mx_MainSplit_video"; mainSplitBody = { const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu(); const canCreateRoom = shouldShowComponent(UIComponent.CreateRooms); const canCreateSpace = shouldShowComponent(UIComponent.CreateSpaces); - const voiceRoomsEnabled = useFeatureEnabled("feature_voice_rooms"); + const videoRoomsEnabled = useFeatureEnabled("feature_video_rooms"); let contextMenu; if (menuDisplayed) { @@ -339,7 +339,7 @@ const SpaceLandingAddButton = ({ space }) => { } }} /> - { voiceRoomsEnabled && { diff --git a/src/components/views/context_menus/RoomContextMenu.tsx b/src/components/views/context_menus/RoomContextMenu.tsx index 5d7d0667c75..35ecf97a9ca 100644 --- a/src/components/views/context_menus/RoomContextMenu.tsx +++ b/src/components/views/context_menus/RoomContextMenu.tsx @@ -105,7 +105,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { } const isDm = DMRoomMap.shared().getUserIdForRoomId(room.roomId); - const isVideoRoom = useFeatureEnabled("feature_voice_rooms") && room.isCallRoom(); + const isVideoRoom = useFeatureEnabled("feature_video_rooms") && room.isCallRoom(); let inviteOption: JSX.Element; if (room.canInvite(cli.getUserId()) && !isDm) { diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index 39483989ec7..65654f37ea2 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -269,7 +269,7 @@ const RoomSummaryCard: React.FC = ({ room, onClose }) => { const isRoomEncrypted = useIsEncrypted(cli, room); const roomContext = useContext(RoomContext); const e2eStatus = roomContext.e2eStatus; - const isVideoRoom = useFeatureEnabled("feature_voice_rooms") && room.isCallRoom(); + const isVideoRoom = useFeatureEnabled("feature_video_rooms") && room.isCallRoom(); const alias = room.getCanonicalAlias() || room.getAltAliases()[0] || ""; const header = diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index 85d6563e483..b7e1f87dc5b 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -236,7 +236,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => { tooltip={canAddRooms ? undefined : _t("You do not have permissions to create new rooms in this space")} /> - { SettingsStore.getValue("feature_voice_rooms") && { @@ -280,7 +280,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => { PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateRoomItem", e); }} /> - { SettingsStore.getValue("feature_voice_rooms") && { diff --git a/src/components/views/rooms/RoomListHeader.tsx b/src/components/views/rooms/RoomListHeader.tsx index 7fe28758825..cc85c4e6dac 100644 --- a/src/components/views/rooms/RoomListHeader.tsx +++ b/src/components/views/rooms/RoomListHeader.tsx @@ -128,7 +128,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { const allRoomsInHome = useEventEmitterState(SpaceStore.instance, UPDATE_HOME_BEHAVIOUR, () => { return SpaceStore.instance.allRoomsInHome; }); - const voiceRoomsEnabled = useFeatureEnabled("feature_voice_rooms"); + const videoRoomsEnabled = useFeatureEnabled("feature_video_rooms"); const pendingActions = usePendingActions(); const filterCondition = RoomListStore.instance.getFirstNameFilterCondition(); @@ -211,7 +211,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { closePlusMenu(); }} /> - { voiceRoomsEnabled && { @@ -302,7 +302,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { closePlusMenu(); }} /> - { voiceRoomsEnabled && { diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 781934efb4a..a2557506e2a 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -52,15 +52,15 @@ import IconizedContextMenu, { IconizedContextMenuOptionList, IconizedContextMenuRadio, } from "../context_menus/IconizedContextMenu"; -import VoiceChannelStore, { VoiceChannelEvent, IJitsiParticipant } from "../../../stores/VoiceChannelStore"; -import { getConnectedMembers } from "../../../utils/VoiceChannelUtils"; +import VideoChannelStore, { VideoChannelEvent, IJitsiParticipant } from "../../../stores/VideoChannelStore"; +import { getConnectedMembers } from "../../../utils/VideoChannelUtils"; import { replaceableComponent } from "../../../utils/replaceableComponent"; import PosthogTrackers from "../../../PosthogTrackers"; import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload"; import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts"; import { getKeyBindingsManager } from "../../../KeyBindingsManager"; -enum VoiceStatus { +enum VideoStatus { Disconnected, Connected, } @@ -79,10 +79,10 @@ interface IState { notificationsMenuPosition: PartialDOMRect; generalMenuPosition: PartialDOMRect; messagePreview?: string; - voiceStatus: VoiceStatus; - // Active voice channel members, according to room state - voiceMembers: RoomMember[]; - // Active voice channel members, according to Jitsi + videoStatus: VideoStatus; + // Active video channel members, according to room state + videoMembers: RoomMember[]; + // Active video channel members, according to Jitsi jitsiParticipants: IJitsiParticipant[]; } @@ -102,12 +102,12 @@ export default class RoomTile extends React.PureComponent { private roomTileRef = createRef(); private notificationState: NotificationState; private roomProps: RoomEchoChamber; - private isVoiceRoom: boolean; + private isVideoRoom: boolean; constructor(props: IProps) { super(props); - const voiceConnected = VoiceChannelStore.instance.roomId === this.props.room.roomId; + const videoConnected = VideoChannelStore.instance.roomId === this.props.room.roomId; this.state = { selected: ActiveRoomObserver.activeRoomId === this.props.room.roomId, @@ -115,15 +115,15 @@ export default class RoomTile extends React.PureComponent { generalMenuPosition: null, // generatePreview() will return nothing if the user has previews disabled messagePreview: "", - voiceStatus: voiceConnected ? VoiceStatus.Connected : VoiceStatus.Disconnected, - voiceMembers: getConnectedMembers(this.props.room.currentState), - jitsiParticipants: voiceConnected ? VoiceChannelStore.instance.participants : [], + videoStatus: videoConnected ? VideoStatus.Connected : VideoStatus.Disconnected, + videoMembers: getConnectedMembers(this.props.room.currentState), + jitsiParticipants: videoConnected ? VideoChannelStore.instance.participants : [], }; this.generatePreview(); this.notificationState = RoomNotificationStateStore.instance.getRoomState(this.props.room); this.roomProps = EchoChamber.forRoom(this.props.room); - this.isVoiceRoom = SettingsStore.getValue("feature_voice_rooms") && this.props.room.isCallRoom(); + this.isVideoRoom = SettingsStore.getValue("feature_video_rooms") && this.props.room.isCallRoom(); } private onRoomNameUpdate = (room: Room) => { @@ -162,9 +162,9 @@ export default class RoomTile extends React.PureComponent { MessagePreviewStore.getPreviewChangedEventName(this.props.room), this.onRoomPreviewChanged, ); - prevProps.room?.currentState?.off(RoomStateEvent.Events, this.updateVoiceMembers); - this.props.room?.currentState?.on(RoomStateEvent.Events, this.updateVoiceMembers); - this.updateVoiceStatus(); + prevProps.room?.currentState?.off(RoomStateEvent.Events, this.updateVideoMembers); + this.props.room?.currentState?.on(RoomStateEvent.Events, this.updateVideoMembers); + this.updateVideoStatus(); prevProps.room?.off(RoomEvent.Name, this.onRoomNameUpdate); this.props.room?.on(RoomEvent.Name, this.onRoomNameUpdate); } @@ -185,12 +185,12 @@ export default class RoomTile extends React.PureComponent { this.notificationState.on(NotificationStateEvents.Update, this.onNotificationUpdate); this.roomProps.on(PROPERTY_UPDATED, this.onRoomPropertyUpdate); this.props.room?.on(RoomEvent.Name, this.onRoomNameUpdate); - this.props.room?.currentState?.on(RoomStateEvent.Events, this.updateVoiceMembers); + this.props.room?.currentState?.on(RoomStateEvent.Events, this.updateVideoMembers); - VoiceChannelStore.instance.on(VoiceChannelEvent.Connect, this.updateVoiceStatus); - VoiceChannelStore.instance.on(VoiceChannelEvent.Disconnect, this.updateVoiceStatus); - if (VoiceChannelStore.instance.roomId === this.props.room.roomId) { - VoiceChannelStore.instance.on(VoiceChannelEvent.Participants, this.updateJitsiParticipants); + VideoChannelStore.instance.on(VideoChannelEvent.Connect, this.updateVideoStatus); + VideoChannelStore.instance.on(VideoChannelEvent.Disconnect, this.updateVideoStatus); + if (VideoChannelStore.instance.roomId === this.props.room.roomId) { + VideoChannelStore.instance.on(VideoChannelEvent.Participants, this.updateJitsiParticipants); } } @@ -201,7 +201,7 @@ export default class RoomTile extends React.PureComponent { MessagePreviewStore.getPreviewChangedEventName(this.props.room), this.onRoomPreviewChanged, ); - this.props.room.currentState.off(RoomStateEvent.Events, this.updateVoiceMembers); + this.props.room.currentState.off(RoomStateEvent.Events, this.updateVideoMembers); this.props.room.off(RoomEvent.Name, this.onRoomNameUpdate); } ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); @@ -209,8 +209,8 @@ export default class RoomTile extends React.PureComponent { this.notificationState.off(NotificationStateEvents.Update, this.onNotificationUpdate); this.roomProps.off(PROPERTY_UPDATED, this.onRoomPropertyUpdate); - VoiceChannelStore.instance.off(VoiceChannelEvent.Connect, this.updateVoiceStatus); - VoiceChannelStore.instance.off(VoiceChannelEvent.Disconnect, this.updateVoiceStatus); + VideoChannelStore.instance.off(VideoChannelEvent.Connect, this.updateVideoStatus); + VideoChannelStore.instance.off(VideoChannelEvent.Disconnect, this.updateVideoStatus); } private onAction = (payload: ActionPayload) => { @@ -585,17 +585,17 @@ export default class RoomTile extends React.PureComponent { ); } - private updateVoiceMembers = () => { - this.setState({ voiceMembers: getConnectedMembers(this.props.room.currentState) }); + private updateVideoMembers = () => { + this.setState({ videoMembers: getConnectedMembers(this.props.room.currentState) }); }; - private updateVoiceStatus = () => { - if (VoiceChannelStore.instance.roomId === this.props.room?.roomId) { - this.setState({ voiceStatus: VoiceStatus.Connected }); - VoiceChannelStore.instance.on(VoiceChannelEvent.Participants, this.updateJitsiParticipants); + private updateVideoStatus = () => { + if (VideoChannelStore.instance.roomId === this.props.room?.roomId) { + this.setState({ videoStatus: VideoStatus.Connected }); + VideoChannelStore.instance.on(VideoChannelEvent.Participants, this.updateJitsiParticipants); } else { - this.setState({ voiceStatus: VoiceStatus.Disconnected }); - VoiceChannelStore.instance.off(VoiceChannelEvent.Participants, this.updateJitsiParticipants); + this.setState({ videoStatus: VideoStatus.Disconnected }); + VideoChannelStore.instance.off(VideoChannelEvent.Participants, this.updateJitsiParticipants); } }; @@ -630,18 +630,18 @@ export default class RoomTile extends React.PureComponent { } let subtitle; - if (this.isVoiceRoom) { + if (this.isVideoRoom) { let videoText: string; let videoActive: boolean; let participantCount: number; - switch (this.state.voiceStatus) { - case VoiceStatus.Disconnected: + switch (this.state.videoStatus) { + case VideoStatus.Disconnected: videoText = _t("Video"); videoActive = false; - participantCount = this.state.voiceMembers.length; + participantCount = this.state.videoMembers.length; break; - case VoiceStatus.Connected: + case VideoStatus.Connected: videoText = _t("Connected"); videoActive = true; participantCount = this.state.jitsiParticipants.length; diff --git a/src/createRoom.ts b/src/createRoom.ts index a092eb7acd1..adfca7dd3a9 100644 --- a/src/createRoom.ts +++ b/src/createRoom.ts @@ -42,7 +42,7 @@ import { isJoinedOrNearlyJoined } from "./utils/membership"; import { VIRTUAL_ROOM_EVENT_TYPE } from "./CallHandler"; import SpaceStore from "./stores/spaces/SpaceStore"; import { makeSpaceParentEvent } from "./utils/space"; -import { VOICE_CHANNEL_MEMBER, addVoiceChannel } from "./utils/VoiceChannelUtils"; +import { VIDEO_CHANNEL_MEMBER, addVideoChannel } from "./utils/VideoChannelUtils"; import { Action } from "./dispatcher/actions"; import ErrorDialog from "./components/views/dialogs/ErrorDialog"; import Spinner from "./components/views/elements/Spinner"; @@ -128,11 +128,11 @@ export default async function createRoom(opts: IOpts): Promise { [RoomCreateTypeField]: opts.roomType, }; - // In video rooms, allow all users to send voice member updates + // In video rooms, allow all users to send video member updates if (opts.roomType === RoomType.UnstableCall) { createOpts.power_level_content_override = { events: { - [VOICE_CHANNEL_MEMBER]: 0, + [VIDEO_CHANNEL_MEMBER]: 0, // Annoyingly, we have to reiterate all the defaults here [EventType.RoomName]: 50, [EventType.RoomAvatar]: 50, @@ -264,7 +264,7 @@ export default async function createRoom(opts: IOpts): Promise { }).then(() => { // Set up video rooms with a Jitsi widget if (opts.roomType === RoomType.UnstableCall) { - return addVoiceChannel(roomId, createOpts.name); + return addVideoChannel(roomId, createOpts.name); } }).then(function() { // NB createRoom doesn't block on the client seeing the echo that the diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 29aa22b5b99..f25a4bf8ce0 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -237,7 +237,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { default: false, controller: new CustomStatusController(), }, - "feature_voice_rooms": { + "feature_video_rooms": { isFeature: true, labsGroup: LabGroup.Rooms, displayName: _td("Video rooms (under active development)"), diff --git a/src/stores/VoiceChannelStore.ts b/src/stores/VideoChannelStore.ts similarity index 79% rename from src/stores/VoiceChannelStore.ts rename to src/stores/VideoChannelStore.ts index 1dd757b44ce..b647b1033be 100644 --- a/src/stores/VoiceChannelStore.ts +++ b/src/stores/VideoChannelStore.ts @@ -23,14 +23,14 @@ import { ElementWidgetActions } from "./widgets/ElementWidgetActions"; import { WidgetMessagingStore } from "./widgets/WidgetMessagingStore"; import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "./ActiveWidgetStore"; import { - VOICE_CHANNEL, - VOICE_CHANNEL_MEMBER, - IVoiceChannelMemberContent, - getVoiceChannel, -} from "../utils/VoiceChannelUtils"; + VIDEO_CHANNEL, + VIDEO_CHANNEL_MEMBER, + IVideoChannelMemberContent, + getVideoChannel, +} from "../utils/VideoChannelUtils"; import WidgetUtils from "../utils/WidgetUtils"; -export enum VoiceChannelEvent { +export enum VideoChannelEvent { Connect = "connect", Disconnect = "disconnect", Participants = "participants", @@ -44,16 +44,16 @@ export interface IJitsiParticipant { } /* - * Holds information about the currently active voice channel. + * Holds information about the currently active video channel. */ -export default class VoiceChannelStore extends EventEmitter { - private static _instance: VoiceChannelStore; +export default class VideoChannelStore extends EventEmitter { + private static _instance: VideoChannelStore; - public static get instance(): VoiceChannelStore { - if (!VoiceChannelStore._instance) { - VoiceChannelStore._instance = new VoiceChannelStore(); + public static get instance(): VideoChannelStore { + if (!VideoChannelStore._instance) { + VideoChannelStore._instance = new VideoChannelStore(); } - return VoiceChannelStore._instance; + return VideoChannelStore._instance; } private readonly cli = MatrixClientPeg.get(); @@ -78,11 +78,11 @@ export default class VoiceChannelStore extends EventEmitter { }; private setConnected = async (roomId: string) => { - const jitsi = getVoiceChannel(roomId); - if (!jitsi) throw new Error(`No voice channel in room ${roomId}`); + const jitsi = getVideoChannel(roomId); + if (!jitsi) throw new Error(`No video channel in room ${roomId}`); const messaging = WidgetMessagingStore.instance.getMessagingForUid(WidgetUtils.getWidgetUid(jitsi)); - if (!messaging) throw new Error(`Failed to bind voice channel in room ${roomId}`); + if (!messaging) throw new Error(`Failed to bind video channel in room ${roomId}`); this.activeChannel = messaging; this._roomId = roomId; @@ -91,7 +91,7 @@ export default class VoiceChannelStore extends EventEmitter { this.activeChannel.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup); this.activeChannel.on(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants); - this.emit(VoiceChannelEvent.Connect); + this.emit(VideoChannelEvent.Connect); // Tell others that we're connected, by adding our device to room state await this.updateDevices(devices => Array.from(new Set(devices).add(this.cli.getDeviceId()))); @@ -114,7 +114,7 @@ export default class VoiceChannelStore extends EventEmitter { } finally { // Save this for last, since updateDevices needs the room ID this._roomId = null; - this.emit(VoiceChannelEvent.Disconnect); + this.emit(VideoChannelEvent.Disconnect); } }; @@ -129,11 +129,11 @@ export default class VoiceChannelStore extends EventEmitter { } const devices = this.cli.getRoom(this.roomId) - .currentState.getStateEvents(VOICE_CHANNEL_MEMBER, this.cli.getUserId()) - ?.getContent()?.devices ?? []; + .currentState.getStateEvents(VIDEO_CHANNEL_MEMBER, this.cli.getUserId()) + ?.getContent()?.devices ?? []; await this.cli.sendStateEvent( - this.roomId, VOICE_CHANNEL_MEMBER, { devices: fn(devices) }, this.cli.getUserId(), + this.roomId, VIDEO_CHANNEL_MEMBER, { devices: fn(devices) }, this.cli.getUserId(), ); }; @@ -144,18 +144,18 @@ export default class VoiceChannelStore extends EventEmitter { private onParticipants = (ev: CustomEvent) => { this._participants = ev.detail.data.participants as IJitsiParticipant[]; - this.emit(VoiceChannelEvent.Participants, ev.detail.data.participants); + this.emit(VideoChannelEvent.Participants, ev.detail.data.participants); this.ack(ev); }; private onActiveWidgetUpdate = async () => { if (this.activeChannel) { - // We got disconnected from the previous voice channel, so clean up + // We got disconnected from the previous video channel, so clean up await this.setDisconnected(); } - // If the new active widget is a voice channel, that means we joined - if (ActiveWidgetStore.instance.getPersistentWidgetId() === VOICE_CHANNEL) { + // If the new active widget is a video channel, that means we joined + if (ActiveWidgetStore.instance.getPersistentWidgetId() === VIDEO_CHANNEL) { await this.setConnected(ActiveWidgetStore.instance.getPersistentRoomId()); } }; diff --git a/src/utils/VoiceChannelUtils.ts b/src/utils/VideoChannelUtils.ts similarity index 72% rename from src/utils/VoiceChannelUtils.ts rename to src/utils/VideoChannelUtils.ts index 5d1d786cd56..d989324ed40 100644 --- a/src/utils/VoiceChannelUtils.ts +++ b/src/utils/VideoChannelUtils.ts @@ -22,26 +22,26 @@ import WidgetStore, { IApp } from "../stores/WidgetStore"; import { WidgetType } from "../widgets/WidgetType"; import WidgetUtils from "./WidgetUtils"; -export const VOICE_CHANNEL = "io.element.voice"; -export const VOICE_CHANNEL_MEMBER = "io.element.voice.member"; +export const VIDEO_CHANNEL = "io.element.video"; +export const VIDEO_CHANNEL_MEMBER = "io.element.video.member"; -export interface IVoiceChannelMemberContent { +export interface IVideoChannelMemberContent { // Connected device IDs devices: string[]; } -export const getVoiceChannel = (roomId: string): IApp => { +export const getVideoChannel = (roomId: string): IApp => { const apps = WidgetStore.instance.getApps(roomId); - return apps.find(app => WidgetType.JITSI.matches(app.type) && app.id === VOICE_CHANNEL); + return apps.find(app => WidgetType.JITSI.matches(app.type) && app.id === VIDEO_CHANNEL); }; -export const addVoiceChannel = async (roomId: string, roomName: string) => { - await WidgetUtils.addJitsiWidget(roomId, CallType.Voice, "Video channel", VOICE_CHANNEL, roomName); +export const addVideoChannel = async (roomId: string, roomName: string) => { + await WidgetUtils.addJitsiWidget(roomId, CallType.Video, "Video channel", VIDEO_CHANNEL, roomName); }; export const getConnectedMembers = (state: RoomState): RoomMember[] => - state.getStateEvents(VOICE_CHANNEL_MEMBER) + state.getStateEvents(VIDEO_CHANNEL_MEMBER) // Must have a device connected and still be joined to the room - .filter(e => e.getContent().devices?.length) + .filter(e => e.getContent().devices?.length) .map(e => state.getMember(e.getStateKey())) .filter(member => member.membership === "join"); diff --git a/src/utils/WidgetUtils.ts b/src/utils/WidgetUtils.ts index 107141f54c6..8537e035837 100644 --- a/src/utils/WidgetUtils.ts +++ b/src/utils/WidgetUtils.ts @@ -36,7 +36,7 @@ import { Jitsi } from "../widgets/Jitsi"; import { objectClone } from "./objects"; import { _t } from "../languageHandler"; import { IApp } from "../stores/WidgetStore"; -import { VOICE_CHANNEL } from "./VoiceChannelUtils"; +import { VIDEO_CHANNEL } from "./VideoChannelUtils"; // How long we wait for the state event echo to come back from the server // before waitFor[Room/User]Widget rejects its promise @@ -470,7 +470,7 @@ export default class WidgetUtils { conferenceId: confId, roomName: oobRoomName ?? MatrixClientPeg.get().getRoom(roomId)?.name, isAudioOnly: type === CallType.Voice, - isVideoChannel: widgetId === VOICE_CHANNEL, + isVideoChannel: widgetId === VIDEO_CHANNEL, domain, auth, }); diff --git a/test/components/views/rooms/RoomTile-test.tsx b/test/components/views/rooms/RoomTile-test.tsx index eaa791751e9..b0a98c8b3c3 100644 --- a/test/components/views/rooms/RoomTile-test.tsx +++ b/test/components/views/rooms/RoomTile-test.tsx @@ -28,19 +28,19 @@ import { mkRoom, mkEvent, } from "../../../test-utils"; -import { stubVoiceChannelStore } from "../../../test-utils/voice"; +import { stubVideoChannelStore } from "../../../test-utils/video"; import RoomTile from "../../../../src/components/views/rooms/RoomTile"; import SettingsStore from "../../../../src/settings/SettingsStore"; import { DefaultTagID } from "../../../../src/stores/room-list/models"; import DMRoomMap from "../../../../src/utils/DMRoomMap"; -import { VOICE_CHANNEL_MEMBER } from "../../../../src/utils/VoiceChannelUtils"; +import { VIDEO_CHANNEL_MEMBER } from "../../../../src/utils/VideoChannelUtils"; import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; import PlatformPeg from "../../../../src/PlatformPeg"; import BasePlatform from "../../../../src/BasePlatform"; -const mkVoiceChannelMember = (userId: string, devices: string[]): MatrixEvent => mkEvent({ +const mkVideoChannelMember = (userId: string, devices: string[]): MatrixEvent => mkEvent({ event: true, - type: VOICE_CHANNEL_MEMBER, + type: VIDEO_CHANNEL_MEMBER, room: "!1:example.org", user: userId, skey: userId, @@ -57,7 +57,7 @@ describe("RoomTile", () => { beforeEach(() => { const realGetValue = SettingsStore.getValue; SettingsStore.getValue = (name: string, roomId?: string): T => { - if (name === "feature_voice_rooms") { + if (name === "feature_video_rooms") { return true as unknown as T; } return realGetValue(name, roomId); @@ -65,7 +65,7 @@ describe("RoomTile", () => { stubClient(); cli = mocked(MatrixClientPeg.get()); - store = stubVoiceChannelStore(); + store = stubVideoChannelStore(); DMRoomMap.makeShared(); }); @@ -98,11 +98,11 @@ describe("RoomTile", () => { it("displays connected members", () => { mocked(room.currentState).getStateEvents.mockImplementation(mockStateEventImplementation([ // A user connected from 2 devices - mkVoiceChannelMember("@alice:example.org", ["device 1", "device 2"]), + mkVideoChannelMember("@alice:example.org", ["device 1", "device 2"]), // A disconnected user - mkVoiceChannelMember("@bob:example.org", []), + mkVideoChannelMember("@bob:example.org", []), // A user that claims to have a connected device, but has left the room - mkVoiceChannelMember("@chris:example.org", ["device 1"]), + mkVideoChannelMember("@chris:example.org", ["device 1"]), ])); mocked(room.currentState).getMember.mockImplementation(userId => ({ diff --git a/test/stores/VoiceChannelStore-test.ts b/test/stores/VideoChannelStore-test.ts similarity index 73% rename from test/stores/VoiceChannelStore-test.ts rename to test/stores/VideoChannelStore-test.ts index 087ff1cf738..e1420195c17 100644 --- a/test/stores/VoiceChannelStore-test.ts +++ b/test/stores/VideoChannelStore-test.ts @@ -22,23 +22,23 @@ import { MatrixClientPeg } from "../../src/MatrixClientPeg"; import WidgetStore from "../../src/stores/WidgetStore"; import ActiveWidgetStore from "../../src/stores/ActiveWidgetStore"; import { WidgetMessagingStore } from "../../src/stores/widgets/WidgetMessagingStore"; -import VoiceChannelStore, { VoiceChannelEvent } from "../../src/stores/VoiceChannelStore"; -import { VOICE_CHANNEL } from "../../src/utils/VoiceChannelUtils"; +import VideoChannelStore, { VideoChannelEvent } from "../../src/stores/VideoChannelStore"; +import { VIDEO_CHANNEL } from "../../src/utils/VideoChannelUtils"; -describe("VoiceChannelStore", () => { +describe("VideoChannelStore", () => { stubClient(); mkRoom(MatrixClientPeg.get(), "!1:example.org"); - const voiceStore = VoiceChannelStore.instance; + const videoStore = VideoChannelStore.instance; const widgetStore = ActiveWidgetStore.instance; jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([{ - id: VOICE_CHANNEL, + id: VIDEO_CHANNEL, eventId: "$1:example.org", roomId: "!1:example.org", type: MatrixWidgetType.JitsiMeet, url: "", - name: "Voice channel", + name: "Video channel", creatorUserId: "@alice:example.org", avatar_url: null, }]); @@ -53,31 +53,31 @@ describe("VoiceChannelStore", () => { } as unknown as ClientWidgetApi); beforeEach(() => { - voiceStore.start(); + videoStore.start(); }); afterEach(() => { - voiceStore.stop(); + videoStore.stop(); jest.clearAllMocks(); }); it("tracks connection state", async () => { - expect(voiceStore.roomId).toBeFalsy(); + expect(videoStore.roomId).toBeFalsy(); const waitForConnect = new Promise(resolve => - voiceStore.once(VoiceChannelEvent.Connect, resolve), + videoStore.once(VideoChannelEvent.Connect, resolve), ); - widgetStore.setWidgetPersistence(VOICE_CHANNEL, "!1:example.org", true); + widgetStore.setWidgetPersistence(VIDEO_CHANNEL, "!1:example.org", true); await waitForConnect; - expect(voiceStore.roomId).toEqual("!1:example.org"); + expect(videoStore.roomId).toEqual("!1:example.org"); const waitForDisconnect = new Promise(resolve => - voiceStore.once(VoiceChannelEvent.Disconnect, resolve), + videoStore.once(VideoChannelEvent.Disconnect, resolve), ); - widgetStore.setWidgetPersistence(VOICE_CHANNEL, "!1:example.org", false); + widgetStore.setWidgetPersistence(VIDEO_CHANNEL, "!1:example.org", false); await waitForDisconnect; - expect(voiceStore.roomId).toBeFalsy(); + expect(videoStore.roomId).toBeFalsy(); }); }); diff --git a/test/test-utils/index.ts b/test/test-utils/index.ts index b14bda3cbb6..0859bd976b3 100644 --- a/test/test-utils/index.ts +++ b/test/test-utils/index.ts @@ -4,6 +4,6 @@ export * from './location'; export * from './platform'; export * from './room'; export * from './test-utils'; -// TODO @@TR: Export voice.ts, which currently isn't exported here because it causes all tests to depend on skinning +// TODO @@TR: Export video.ts, which currently isn't exported here because it causes all tests to depend on skinning export * from './wrappers'; export * from './utilities'; diff --git a/test/test-utils/voice.ts b/test/test-utils/video.ts similarity index 65% rename from test/test-utils/voice.ts rename to test/test-utils/video.ts index b0ce5f82d90..91309452158 100644 --- a/test/test-utils/voice.ts +++ b/test/test-utils/video.ts @@ -16,24 +16,24 @@ limitations under the License. import { EventEmitter } from "events"; -import VoiceChannelStore, { VoiceChannelEvent } from "../../src/stores/VoiceChannelStore"; +import VideoChannelStore, { VideoChannelEvent } from "../../src/stores/VideoChannelStore"; -class StubVoiceChannelStore extends EventEmitter { +class StubVideoChannelStore extends EventEmitter { private _roomId: string; public get roomId(): string { return this._roomId; } public connect = (roomId: string) => { this._roomId = roomId; - this.emit(VoiceChannelEvent.Connect); + this.emit(VideoChannelEvent.Connect); }; public disconnect = () => { this._roomId = null; - this.emit(VoiceChannelEvent.Disconnect); + this.emit(VideoChannelEvent.Disconnect); }; } -export const stubVoiceChannelStore = (): StubVoiceChannelStore => { - const store = new StubVoiceChannelStore(); - jest.spyOn(VoiceChannelStore, "instance", "get").mockReturnValue(store as unknown as VoiceChannelStore); +export const stubVideoChannelStore = (): StubVideoChannelStore => { + const store = new StubVideoChannelStore(); + jest.spyOn(VideoChannelStore, "instance", "get").mockReturnValue(store as unknown as VideoChannelStore); return store; };