{
displayBadge={this.props.isMinimized}
tooltipProps={{ tabIndex: isActive ? 0 : -1 }}
/>
-
-
- { titleContainer }
- { badge }
- { this.renderGeneralMenu() }
- { this.renderNotificationsMenu(isActive) }
-
- { this.renderVoiceChannel() }
-
+ { titleContainer }
+ { badge }
+ { this.renderGeneralMenu() }
+ { this.renderNotificationsMenu(isActive) }
}
diff --git a/src/components/views/voip/VoiceChannelRadio.tsx b/src/components/views/voip/VoiceChannelRadio.tsx
deleted file mode 100644
index 3a3e362e5bb..00000000000
--- a/src/components/views/voip/VoiceChannelRadio.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-Copyright 2022 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import React, { FC, useState, useContext } from "react";
-import classNames from "classnames";
-
-import { _t } from "../../../languageHandler";
-import { useEventEmitter } from "../../../hooks/useEventEmitter";
-import MatrixClientContext from "../../../contexts/MatrixClientContext";
-import VoiceChannelStore, { VoiceChannelEvent } from "../../../stores/VoiceChannelStore";
-import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
-import AccessibleButton from "../elements/AccessibleButton";
-import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
-
-const _VoiceChannelRadio: FC<{ roomId: string }> = ({ roomId }) => {
- const cli = useContext(MatrixClientContext);
- const room = cli.getRoom(roomId);
- const store = VoiceChannelStore.instance;
-
- const [audioMuted, setAudioMuted] = useState
(store.audioMuted);
- const [videoMuted, setVideoMuted] = useState(store.videoMuted);
-
- useEventEmitter(store, VoiceChannelEvent.MuteAudio, () => setAudioMuted(true));
- useEventEmitter(store, VoiceChannelEvent.UnmuteAudio, () => setAudioMuted(false));
- useEventEmitter(store, VoiceChannelEvent.MuteVideo, () => setVideoMuted(true));
- useEventEmitter(store, VoiceChannelEvent.UnmuteVideo, () => setVideoMuted(false));
-
- return
-
-
-
-
{ _t("Connected") }
-
{ room.name }
-
-
store.disconnect()}
- />
-
-
-
videoMuted ? store.unmuteVideo() : store.muteVideo()}
- >
- { videoMuted ? _t("Video off") : _t("Video") }
-
-
audioMuted ? store.unmuteAudio() : store.muteAudio()}
- >
- { audioMuted ? _t("Mic off") : _t("Mic") }
-
-
-
;
-};
-
-const VoiceChannelRadio: FC<{}> = () => {
- const store = VoiceChannelStore.instance;
-
- const [activeChannel, setActiveChannel] = useState(VoiceChannelStore.instance.roomId);
- useEventEmitter(store, VoiceChannelEvent.Connect, () =>
- setActiveChannel(VoiceChannelStore.instance.roomId),
- );
- useEventEmitter(store, VoiceChannelEvent.Disconnect, () =>
- setActiveChannel(null),
- );
-
- return activeChannel ? <_VoiceChannelRadio roomId={activeChannel} /> : null;
-};
-
-export default VoiceChannelRadio;
diff --git a/src/createRoom.ts b/src/createRoom.ts
index 91eb1b45e95..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 voice 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,
@@ -262,9 +262,9 @@ export default async function createRoom(opts: IOpts): Promise {
return SpaceStore.instance.addRoomToSpace(opts.parentSpace, roomId, [client.getDomain()], opts.suggested);
}
}).then(() => {
- // Set up voice rooms with a Jitsi widget
+ // 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/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 05182353e2f..dea47408e99 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -868,7 +868,7 @@
"Message Pinning": "Message Pinning",
"Threaded messaging": "Threaded messaging",
"Custom user status messages": "Custom user status messages",
- "Voice & video rooms (under active development)": "Voice & video rooms (under active development)",
+ "Video rooms (under active development)": "Video rooms (under active development)",
"Render simple counters in room header": "Render simple counters in room header",
"Multiple integration managers (requires manual setup)": "Multiple integration managers (requires manual setup)",
"Try out new ways to ignore people (experimental)": "Try out new ways to ignore people (experimental)",
@@ -1002,12 +1002,6 @@
"Your camera is turned off": "Your camera is turned off",
"Your camera is still enabled": "Your camera is still enabled",
"Dial": "Dial",
- "Connected": "Connected",
- "Disconnect": "Disconnect",
- "Video off": "Video off",
- "Video": "Video",
- "Mic off": "Mic off",
- "Mic": "Mic",
"Dialpad": "Dialpad",
"Mute the microphone": "Mute the microphone",
"Unmute the microphone": "Unmute the microphone",
@@ -1359,6 +1353,7 @@
"The identity server you have chosen does not have any terms of service.": "The identity server you have chosen does not have any terms of service.",
"Disconnect identity server": "Disconnect identity server",
"Disconnect from the identity server ?": "Disconnect from the identity server ?",
+ "Disconnect": "Disconnect",
"You should remove your personal data from identity server before disconnecting. Unfortunately, identity server is currently offline or cannot be reached.": "You should remove your personal data from identity server before disconnecting. Unfortunately, identity server is currently offline or cannot be reached.",
"You should:": "You should:",
"check your browser plugins for anything that might block the identity server (such as Privacy Badger)": "check your browser plugins for anything that might block the identity server (such as Privacy Badger)",
@@ -1757,8 +1752,9 @@
"Add people": "Add people",
"Start chat": "Start chat",
"Explore rooms": "Explore rooms",
- "Create new room": "Create new room",
+ "New room": "New room",
"You do not have permissions to create new rooms in this space": "You do not have permissions to create new rooms in this space",
+ "New video room": "New video room",
"Add existing room": "Add existing room",
"You do not have permissions to add rooms to this space": "You do not have permissions to add rooms to this space",
"Explore public rooms": "Explore public rooms",
@@ -1851,9 +1847,10 @@
"Low Priority": "Low Priority",
"Copy room link": "Copy room link",
"Leave": "Leave",
- "Join": "Join",
- "Voice room": "Voice room",
- "Connecting...": "Connecting...",
+ "Video": "Video",
+ "Connected": "Connected",
+ "%(count)s participants|other": "%(count)s participants",
+ "%(count)s participants|one": "1 participant",
"%(count)s unread messages including mentions.|other": "%(count)s unread messages including mentions.",
"%(count)s unread messages including mentions.|one": "1 unread mention.",
"%(count)s unread messages.|other": "%(count)s unread messages.",
@@ -2207,6 +2204,7 @@
"Application window": "Application window",
"Share content": "Share content",
"Backspace": "Backspace",
+ "Join": "Join",
"Please create a new issue on GitHub so that we can investigate this bug.": "Please create a new issue on GitHub so that we can investigate this bug.",
"Something went wrong!": "Something went wrong!",
"%(nameList)s %(transitionList)s": "%(nameList)s %(transitionList)s",
@@ -2420,20 +2418,18 @@
"Enable end-to-end encryption": "Enable end-to-end encryption",
"You might enable this if the room will only be used for collaborating with internal teams on your homeserver. This cannot be changed later.": "You might enable this if the room will only be used for collaborating with internal teams on your homeserver. This cannot be changed later.",
"You might disable this if the room will be used for collaborating with external teams who have their own homeserver. This cannot be changed later.": "You might disable this if the room will be used for collaborating with external teams who have their own homeserver. This cannot be changed later.",
+ "Create a video room": "Create a video room",
"Create a room": "Create a room",
"Create a public room": "Create a public room",
"Create a private room": "Create a private room",
- "Room type": "Room type",
- "Text room": "Text room",
- "Voice & video room": "Voice & video room",
- "Room details": "Room details",
"Topic (optional)": "Topic (optional)",
"Room visibility": "Room visibility",
"Private room (invite only)": "Private room (invite only)",
"Public room": "Public room",
"Visible to space members": "Visible to space members",
"Block anyone not part of %(serverName)s from ever joining this room.": "Block anyone not part of %(serverName)s from ever joining this room.",
- "Create Room": "Create Room",
+ "Create video room": "Create video room",
+ "Create room": "Create room",
"Anyone in will be able to find and join.": "Anyone in will be able to find and join.",
"Anyone will be able to find and join this space, not just members of .": "Anyone will be able to find and join this space, not just members of .",
"Only people invited will be able to find and join this space.": "Only people invited will be able to find and join this space.",
@@ -3021,6 +3017,7 @@
"Unable to look up room ID from server": "Unable to look up room ID from server",
"Preview": "Preview",
"View": "View",
+ "Create new room": "Create new room",
"No results for \"%(query)s\"": "No results for \"%(query)s\"",
"Try different words or check for typos. Some results may not be visible as they're private and you need an invite to join them.": "Try different words or check for typos. Some results may not be visible as they're private and you need an invite to join them.",
"Find a room…": "Find a room…",
diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx
index 452c2185c58..f25a4bf8ce0 100644
--- a/src/settings/Settings.tsx
+++ b/src/settings/Settings.tsx
@@ -237,10 +237,10 @@ export const SETTINGS: {[setting: string]: ISetting} = {
default: false,
controller: new CustomStatusController(),
},
- "feature_voice_rooms": {
+ "feature_video_rooms": {
isFeature: true,
labsGroup: LabGroup.Rooms,
- displayName: _td("Voice & video rooms (under active development)"),
+ displayName: _td("Video rooms (under active development)"),
supportedLevels: LEVELS_FEATURE,
default: false,
// Reload to ensure that the left panel etc. get remounted
diff --git a/src/stores/VideoChannelStore.ts b/src/stores/VideoChannelStore.ts
new file mode 100644
index 00000000000..6bd1b621e4d
--- /dev/null
+++ b/src/stores/VideoChannelStore.ts
@@ -0,0 +1,164 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import { EventEmitter } from "events";
+import { logger } from "matrix-js-sdk/src/logger";
+import { ClientWidgetApi, IWidgetApiRequest } from "matrix-widget-api";
+
+import { MatrixClientPeg } from "../MatrixClientPeg";
+import { ElementWidgetActions } from "./widgets/ElementWidgetActions";
+import { WidgetMessagingStore } from "./widgets/WidgetMessagingStore";
+import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "./ActiveWidgetStore";
+import {
+ VIDEO_CHANNEL,
+ VIDEO_CHANNEL_MEMBER,
+ IVideoChannelMemberContent,
+ getVideoChannel,
+} from "../utils/VideoChannelUtils";
+import WidgetUtils from "../utils/WidgetUtils";
+
+export enum VideoChannelEvent {
+ Connect = "connect",
+ Disconnect = "disconnect",
+ Participants = "participants",
+}
+
+export interface IJitsiParticipant {
+ avatarURL: string;
+ displayName: string;
+ formattedDisplayName: string;
+ participantId: string;
+}
+
+/*
+ * Holds information about the currently active video channel.
+ */
+export default class VideoChannelStore extends EventEmitter {
+ private static _instance: VideoChannelStore;
+
+ public static get instance(): VideoChannelStore {
+ if (!VideoChannelStore._instance) {
+ VideoChannelStore._instance = new VideoChannelStore();
+ }
+ return VideoChannelStore._instance;
+ }
+
+ private readonly cli = MatrixClientPeg.get();
+ private activeChannel: ClientWidgetApi;
+ private _roomId: string;
+ private _participants: IJitsiParticipant[];
+
+ public get roomId(): string {
+ return this._roomId;
+ }
+
+ public get participants(): IJitsiParticipant[] {
+ return this._participants;
+ }
+
+ public start = () => {
+ ActiveWidgetStore.instance.on(ActiveWidgetStoreEvent.Update, this.onActiveWidgetUpdate);
+ };
+
+ public stop = () => {
+ ActiveWidgetStore.instance.off(ActiveWidgetStoreEvent.Update, this.onActiveWidgetUpdate);
+ };
+
+ private setConnected = async (roomId: string) => {
+ 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 video channel in room ${roomId}`);
+
+ this.activeChannel = messaging;
+ this._roomId = roomId;
+ this._participants = [];
+
+ this.activeChannel.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
+ this.activeChannel.on(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
+
+ 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())));
+ };
+
+ private setDisconnected = async () => {
+ this.activeChannel.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
+ this.activeChannel.off(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
+
+ this.activeChannel = null;
+ this._participants = null;
+
+ try {
+ // Tell others that we're disconnected, by removing our device from room state
+ await this.updateDevices(devices => {
+ const devicesSet = new Set(devices);
+ devicesSet.delete(this.cli.getDeviceId());
+ return Array.from(devicesSet);
+ });
+ } finally {
+ // Save this for last, since updateDevices needs the room ID
+ this._roomId = null;
+ this.emit(VideoChannelEvent.Disconnect);
+ }
+ };
+
+ private ack = (ev: CustomEvent) => {
+ // Even if we don't have a reply to a given widget action, we still need
+ // to give the widget API something to acknowledge receipt
+ this.activeChannel.transport.reply(ev.detail, {});
+ };
+
+ private updateDevices = async (fn: (devices: string[]) => string[]) => {
+ if (!this.roomId) {
+ logger.error("Tried to update devices while disconnected");
+ return;
+ }
+
+ const room = this.cli.getRoom(this.roomId);
+ const devicesState = room.currentState.getStateEvents(VIDEO_CHANNEL_MEMBER, this.cli.getUserId());
+ const devices = devicesState?.getContent()?.devices ?? [];
+
+ await this.cli.sendStateEvent(
+ this.roomId, VIDEO_CHANNEL_MEMBER, { devices: fn(devices) }, this.cli.getUserId(),
+ );
+ };
+
+ private onHangup = async (ev: CustomEvent) => {
+ this.ack(ev);
+ await this.setDisconnected();
+ };
+
+ private onParticipants = (ev: CustomEvent) => {
+ this._participants = ev.detail.data.participants as IJitsiParticipant[];
+ this.emit(VideoChannelEvent.Participants, ev.detail.data.participants);
+ this.ack(ev);
+ };
+
+ private onActiveWidgetUpdate = async () => {
+ if (this.activeChannel) {
+ // We got disconnected from the previous video channel, so clean up
+ await this.setDisconnected();
+ }
+
+ // 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/stores/VoiceChannelStore.ts b/src/stores/VoiceChannelStore.ts
deleted file mode 100644
index 9e77a0094bf..00000000000
--- a/src/stores/VoiceChannelStore.ts
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
-Copyright 2022 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import { EventEmitter } from "events";
-import { logger } from "matrix-js-sdk/src/logger";
-import { ClientWidgetApi, IWidgetApiRequest } from "matrix-widget-api";
-
-import { MatrixClientPeg } from "../MatrixClientPeg";
-import { ElementWidgetActions } from "./widgets/ElementWidgetActions";
-import { WidgetMessagingStore } from "./widgets/WidgetMessagingStore";
-import {
- VOICE_CHANNEL_MEMBER,
- IVoiceChannelMemberContent,
- getVoiceChannel,
-} from "../utils/VoiceChannelUtils";
-import { timeout } from "../utils/promise";
-import WidgetUtils from "../utils/WidgetUtils";
-
-export enum VoiceChannelEvent {
- Connect = "connect",
- Disconnect = "disconnect",
- Participants = "participants",
- MuteAudio = "mute_audio",
- UnmuteAudio = "unmute_audio",
- MuteVideo = "mute_video",
- UnmuteVideo = "unmute_video",
-}
-
-export interface IJitsiParticipant {
- avatarURL: string;
- displayName: string;
- formattedDisplayName: string;
- participantId: string;
-}
-
-/*
- * Holds information about the currently active voice channel.
- */
-export default class VoiceChannelStore extends EventEmitter {
- private static _instance: VoiceChannelStore;
- private static readonly TIMEOUT = 8000;
-
- public static get instance(): VoiceChannelStore {
- if (!VoiceChannelStore._instance) {
- VoiceChannelStore._instance = new VoiceChannelStore();
- }
- return VoiceChannelStore._instance;
- }
-
- private readonly cli = MatrixClientPeg.get();
- private activeChannel: ClientWidgetApi;
- private _roomId: string;
- private _participants: IJitsiParticipant[];
- private _audioMuted: boolean;
- private _videoMuted: boolean;
-
- public get roomId(): string {
- return this._roomId;
- }
-
- public get participants(): IJitsiParticipant[] {
- return this._participants;
- }
-
- public get audioMuted(): boolean {
- return this._audioMuted;
- }
-
- public get videoMuted(): boolean {
- return this._videoMuted;
- }
-
- public connect = async (roomId: string) => {
- if (this.activeChannel) await this.disconnect();
-
- const jitsi = getVoiceChannel(roomId);
- if (!jitsi) throw new Error(`No voice 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}`);
-
- this.activeChannel = messaging;
- this._roomId = roomId;
-
- // Participant data and mute state will come down the event pipeline very quickly,
- // so prepare in advance
- messaging.on(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
- messaging.on(`action:${ElementWidgetActions.MuteAudio}`, this.onMuteAudio);
- messaging.on(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
- messaging.on(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
- messaging.on(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
-
- // Actually perform the join
- const waitForJoin = this.waitForAction(ElementWidgetActions.JoinCall);
- messaging.transport.send(ElementWidgetActions.JoinCall, {});
- try {
- await waitForJoin;
- } catch (e) {
- // If it timed out, clean up our advance preparations
- this.activeChannel = null;
- this._roomId = null;
-
- messaging.off(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
- messaging.off(`action:${ElementWidgetActions.MuteAudio}`, this.onMuteAudio);
- messaging.off(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
- messaging.off(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
- messaging.off(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
-
- throw e;
- }
-
- messaging.once(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
-
- this.emit(VoiceChannelEvent.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())));
- };
-
- public disconnect = async () => {
- this.assertConnected();
-
- const waitForHangup = this.waitForAction(ElementWidgetActions.HangupCall);
- this.activeChannel.transport.send(ElementWidgetActions.HangupCall, {});
- await waitForHangup;
-
- // onHangup cleans up for us
- };
-
- public muteAudio = async () => {
- this.assertConnected();
-
- const waitForMute = this.waitForAction(ElementWidgetActions.MuteAudio);
- this.activeChannel.transport.send(ElementWidgetActions.MuteAudio, {});
- await waitForMute;
- };
-
- public unmuteAudio = async () => {
- this.assertConnected();
-
- const waitForUnmute = this.waitForAction(ElementWidgetActions.UnmuteAudio);
- this.activeChannel.transport.send(ElementWidgetActions.UnmuteAudio, {});
- await waitForUnmute;
- };
-
- public muteVideo = async () => {
- this.assertConnected();
-
- const waitForMute = this.waitForAction(ElementWidgetActions.MuteVideo);
- this.activeChannel.transport.send(ElementWidgetActions.MuteVideo, {});
- await waitForMute;
- };
-
- public unmuteVideo = async () => {
- this.assertConnected();
-
- const waitForUnmute = this.waitForAction(ElementWidgetActions.UnmuteVideo);
- this.activeChannel.transport.send(ElementWidgetActions.UnmuteVideo, {});
- await waitForUnmute;
- };
-
- private assertConnected = () => {
- if (!this.activeChannel) throw new Error("Not connected to any voice channel");
- };
-
- private waitForAction = async (action: ElementWidgetActions) => {
- const wait = new Promise(resolve =>
- this.activeChannel.once(`action:${action}`, (ev: CustomEvent) => {
- this.ack(ev);
- resolve();
- }),
- );
- if (await timeout(wait, false, VoiceChannelStore.TIMEOUT) === false) {
- throw new Error("Communication with voice channel timed out");
- }
- };
-
- private ack = (ev: CustomEvent) => {
- this.activeChannel.transport.reply(ev.detail, {});
- };
-
- private updateDevices = async (fn: (devices: string[]) => string[]) => {
- if (!this.roomId) {
- logger.error("Tried to update devices while disconnected");
- return;
- }
-
- const devices = this.cli.getRoom(this.roomId)
- .currentState.getStateEvents(VOICE_CHANNEL_MEMBER, this.cli.getUserId())
- ?.getContent()?.devices ?? [];
-
- await this.cli.sendStateEvent(
- this.roomId, VOICE_CHANNEL_MEMBER, { devices: fn(devices) }, this.cli.getUserId(),
- );
- };
-
- private onHangup = async (ev: CustomEvent) => {
- this.ack(ev);
-
- this.activeChannel.off(`action:${ElementWidgetActions.CallParticipants}`, this.onParticipants);
- this.activeChannel.off(`action:${ElementWidgetActions.MuteAudio}`, this.onMuteAudio);
- this.activeChannel.off(`action:${ElementWidgetActions.UnmuteAudio}`, this.onUnmuteAudio);
- this.activeChannel.off(`action:${ElementWidgetActions.MuteVideo}`, this.onMuteVideo);
- this.activeChannel.off(`action:${ElementWidgetActions.UnmuteVideo}`, this.onUnmuteVideo);
-
- this.activeChannel = null;
- this._participants = null;
- this._audioMuted = null;
- this._videoMuted = null;
-
- try {
- // Tell others that we're disconnected, by removing our device from room state
- await this.updateDevices(devices => {
- const devicesSet = new Set(devices);
- devicesSet.delete(this.cli.getDeviceId());
- return Array.from(devicesSet);
- });
- } finally {
- // Save this for last, since updateDevices needs the room ID
- this._roomId = null;
- this.emit(VoiceChannelEvent.Disconnect);
- }
- };
-
- private onParticipants = (ev: CustomEvent) => {
- this._participants = ev.detail.data.participants as IJitsiParticipant[];
- this.emit(VoiceChannelEvent.Participants, ev.detail.data.participants);
- this.ack(ev);
- };
-
- private onMuteAudio = (ev: CustomEvent) => {
- this._audioMuted = true;
- this.emit(VoiceChannelEvent.MuteAudio);
- this.ack(ev);
- };
-
- private onUnmuteAudio = (ev: CustomEvent) => {
- this._audioMuted = false;
- this.emit(VoiceChannelEvent.UnmuteAudio);
- this.ack(ev);
- };
-
- private onMuteVideo = (ev: CustomEvent) => {
- this._videoMuted = true;
- this.emit(VoiceChannelEvent.MuteVideo);
- this.ack(ev);
- };
-
- private onUnmuteVideo = (ev: CustomEvent) => {
- this._videoMuted = false;
- this.emit(VoiceChannelEvent.UnmuteVideo);
- this.ack(ev);
- };
-}
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 bee6388ed4e..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, "Voice 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 1515b77b2c2..8537e035837 100644
--- a/src/utils/WidgetUtils.ts
+++ b/src/utils/WidgetUtils.ts
@@ -36,6 +36,7 @@ import { Jitsi } from "../widgets/Jitsi";
import { objectClone } from "./objects";
import { _t } from "../languageHandler";
import { IApp } from "../stores/WidgetStore";
+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
@@ -469,6 +470,7 @@ export default class WidgetUtils {
conferenceId: confId,
roomName: oobRoomName ?? MatrixClientPeg.get().getRoom(roomId)?.name,
isAudioOnly: type === CallType.Voice,
+ isVideoChannel: widgetId === VIDEO_CHANNEL,
domain,
auth,
});
@@ -515,6 +517,7 @@ export default class WidgetUtils {
'conferenceDomain=$domain',
'conferenceId=$conferenceId',
'isAudioOnly=$isAudioOnly',
+ 'isVideoChannel=$isVideoChannel',
'displayName=$matrix_display_name',
'avatarUrl=$matrix_avatar_url',
'userId=$matrix_user_id',
diff --git a/src/utils/space.tsx b/src/utils/space.tsx
index 442a411af81..9394f56c74a 100644
--- a/src/utils/space.tsx
+++ b/src/utils/space.tsx
@@ -16,6 +16,7 @@ limitations under the License.
import React from "react";
import { Room } from "matrix-js-sdk/src/models/room";
+import { RoomType } from "matrix-js-sdk/src/@types/event";
import { EventType } from "matrix-js-sdk/src/@types/event";
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
@@ -92,12 +93,13 @@ export const showAddExistingRooms = (space: Room): void => {
);
};
-export const showCreateNewRoom = async (space: Room): Promise => {
+export const showCreateNewRoom = async (space: Room, type?: RoomType): Promise => {
const modal = Modal.createTrackedDialog<[boolean, IOpts]>(
"Space Landing",
"Create Room",
CreateRoomDialog,
{
+ type,
defaultPublic: space.getJoinRule() === JoinRule.Public,
parentSpace: space,
},
diff --git a/test/UserActivity-test.js b/test/UserActivity-test.ts
similarity index 100%
rename from test/UserActivity-test.js
rename to test/UserActivity-test.ts
diff --git a/test/autocomplete/QueryMatcher-test.js b/test/autocomplete/QueryMatcher-test.ts
similarity index 100%
rename from test/autocomplete/QueryMatcher-test.js
rename to test/autocomplete/QueryMatcher-test.ts
diff --git a/test/components/views/rooms/RoomTile-test.tsx b/test/components/views/rooms/RoomTile-test.tsx
index 4e960afe46c..b0a98c8b3c3 100644
--- a/test/components/views/rooms/RoomTile-test.tsx
+++ b/test/components/views/rooms/RoomTile-test.tsx
@@ -28,21 +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 MemberAvatar from "../../../../src/components/views/avatars/MemberAvatar";
import SettingsStore from "../../../../src/settings/SettingsStore";
-import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
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,
@@ -59,36 +57,25 @@ 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);
};
stubClient();
- stubVoiceChannelStore();
- DMRoomMap.makeShared();
-
cli = mocked(MatrixClientPeg.get());
- store = VoiceChannelStore.instance;
+ store = stubVideoChannelStore();
+ DMRoomMap.makeShared();
});
afterEach(() => jest.clearAllMocks());
- describe("voice rooms", () => {
+ describe("video rooms", () => {
const room = mkRoom(cli, "!1:example.org");
room.isCallRoom.mockReturnValue(true);
- it("tracks connection state", async () => {
- // Insert a breakpoint in the connect method, so we can see the intermediate connecting state
- let continueJoin;
- const breakpoint = new Promise(resolve => continueJoin = resolve);
- const realConnect = store.connect;
- store.connect = async () => {
- await breakpoint;
- await realConnect();
- };
-
+ it("tracks connection state", () => {
const tile = mount(
{
tag={DefaultTagID.Untagged}
/>,
);
- expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Voice room");
+ expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Video");
- act(() => { tile.simulate("click"); });
+ act(() => { store.connect("!1:example.org"); });
tile.update();
- expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Connecting...");
-
- // Now we confirm the join and wait for the store to update
- const waitForConnect = new Promise(resolve =>
- store.once(VoiceChannelEvent.Connect, resolve),
- );
- continueJoin();
- await waitForConnect;
- // Wait exactly 2 ticks for the room tile to update
- await Promise.resolve();
- await Promise.resolve();
-
- tile.update();
- expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Connected");
-
- await store.disconnect();
+ expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Connected");
+ act(() => { store.disconnect(); });
tile.update();
- expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Voice room");
+ expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Video");
});
- it("displays connected members", async () => {
+ 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 => ({
@@ -152,9 +125,8 @@ describe("RoomTile", () => {
);
// Only Alice should display as connected
- const avatar = tile.find(MemberAvatar);
- expect(avatar.length).toEqual(1);
- expect(avatar.props().member.userId).toEqual("@alice:example.org");
+ const participants = tile.find(".mx_RoomTile_videoParticipants");
+ expect(participants.text()).toEqual("1");
});
});
});
diff --git a/test/components/views/voip/VoiceChannelRadio-test.tsx b/test/components/views/voip/VoiceChannelRadio-test.tsx
deleted file mode 100644
index b42ac0e0893..00000000000
--- a/test/components/views/voip/VoiceChannelRadio-test.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-Copyright 2022 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import React from "react";
-import { mount } from "enzyme";
-import { act } from "react-dom/test-utils";
-import { mocked } from "jest-mock";
-
-import "../../../skinned-sdk";
-import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test-utils";
-import { stubVoiceChannelStore } from "../../../test-utils/voice";
-import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
-import VoiceChannelStore from "../../../../src/stores/VoiceChannelStore";
-import DMRoomMap from "../../../../src/utils/DMRoomMap";
-import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
-
-const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
-
-describe("VoiceChannelRadio", () => {
- const cli = mocked(MatrixClientPeg.get());
- const room = mkStubRoom("!1:example.org", "voice channel", cli);
- room.isCallRoom = () => true;
-
- beforeEach(() => {
- stubClient();
- stubVoiceChannelStore();
- DMRoomMap.makeShared();
- });
-
- it("shows when connecting voice", async () => {
- const radio = mount();
- expect(radio.children().children().exists()).toEqual(false);
-
- act(() => { VoiceChannelStore.instance.connect("!1:example.org"); });
- radio.update();
- expect(radio.children().children().exists()).toEqual(true);
- });
-
- it("hides when disconnecting voice", () => {
- VoiceChannelStore.instance.connect("!1:example.org");
- const radio = mount();
- expect(radio.children().children().exists()).toEqual(true);
-
- act(() => { VoiceChannelStore.instance.disconnect(); });
- radio.update();
- expect(radio.children().children().exists()).toEqual(false);
- });
-
- describe("disconnect button", () => {
- it("works", () => {
- VoiceChannelStore.instance.connect("!1:example.org");
- const radio = mount();
-
- act(() => {
- radio.find("AccessibleButton.mx_VoiceChannelRadio_disconnectButton").simulate("click");
- });
- expect(VoiceChannelStore.instance.disconnect).toHaveBeenCalled();
- });
- });
-
- describe("video button", () => {
- it("works", () => {
- VoiceChannelStore.instance.connect("!1:example.org");
- const radio = mount();
-
- act(() => {
- radio.find("AccessibleButton.mx_VoiceChannelRadio_videoButton").simulate("click");
- });
- expect(VoiceChannelStore.instance.unmuteVideo).toHaveBeenCalled();
-
- act(() => {
- radio.find("AccessibleButton.mx_VoiceChannelRadio_videoButton").simulate("click");
- });
- expect(VoiceChannelStore.instance.muteVideo).toHaveBeenCalled();
- });
- });
-
- describe("audio button", () => {
- it("works", () => {
- VoiceChannelStore.instance.connect("!1:example.org");
- const radio = mount();
-
- act(() => {
- radio.find("AccessibleButton.mx_VoiceChannelRadio_audioButton").simulate("click");
- });
- expect(VoiceChannelStore.instance.unmuteAudio).toHaveBeenCalled();
-
- act(() => {
- radio.find("AccessibleButton.mx_VoiceChannelRadio_audioButton").simulate("click");
- });
- expect(VoiceChannelStore.instance.muteAudio).toHaveBeenCalled();
- });
- });
-});
diff --git a/test/end-to-end-tests/src/usecases/create-room.ts b/test/end-to-end-tests/src/usecases/create-room.ts
index 8736e785bac..b0e7738fb4e 100644
--- a/test/end-to-end-tests/src/usecases/create-room.ts
+++ b/test/end-to-end-tests/src/usecases/create-room.ts
@@ -36,7 +36,7 @@ export async function createRoom(session: ElementSession, roomName: string, encr
const addRoomButton = await roomsSublist.$(".mx_RoomSublist_auxButton");
await addRoomButton.click();
- const createRoomButton = await session.query('.mx_AccessibleButton[aria-label="Create new room"]');
+ const createRoomButton = await session.query('.mx_AccessibleButton[aria-label="New room"]');
await createRoomButton.click();
const roomNameInput = await session.query('.mx_CreateRoomDialog_name input');
diff --git a/test/notifications/ContentRules-test.js b/test/notifications/ContentRules-test.ts
similarity index 81%
rename from test/notifications/ContentRules-test.js
rename to test/notifications/ContentRules-test.ts
index 2b18a18488f..9881a1c1498 100644
--- a/test/notifications/ContentRules-test.js
+++ b/test/notifications/ContentRules-test.ts
@@ -1,5 +1,6 @@
/*
Copyright 2016 OpenMarket Ltd
+Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,16 +15,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-const notifications = require('../../src/notifications');
+import { TweakName, PushRuleActionName, TweakHighlight, TweakSound } from "matrix-js-sdk/src/matrix";
-const ContentRules = notifications.ContentRules;
-const PushRuleVectorState = notifications.PushRuleVectorState;
+import { ContentRules, PushRuleVectorState } from "../../src/notifications";
const NORMAL_RULE = {
actions: [
- "notify",
- { set_tweak: "highlight", value: false },
+ PushRuleActionName.Notify,
+ { set_tweak: TweakName.Highlight, value: false } as TweakHighlight,
],
+ default: false,
enabled: true,
pattern: "vdh2",
rule_id: "vdh2",
@@ -31,10 +32,11 @@ const NORMAL_RULE = {
const LOUD_RULE = {
actions: [
- "notify",
- { set_tweak: "highlight" },
- { set_tweak: "sound", value: "default" },
+ PushRuleActionName.Notify,
+ { set_tweak: TweakName.Highlight } as TweakHighlight,
+ { set_tweak: TweakName.Sound, value: "default" } as TweakSound,
],
+ default: false,
enabled: true,
pattern: "vdh2",
rule_id: "vdh2",
@@ -42,9 +44,9 @@ const LOUD_RULE = {
const USERNAME_RULE = {
actions: [
- "notify",
- { set_tweak: "sound", value: "default" },
- { set_tweak: "highlight" },
+ PushRuleActionName.Notify,
+ { set_tweak: TweakName.Sound, value: "default" } as TweakSound,
+ { set_tweak: TweakName.Highlight } as TweakHighlight,
],
default: true,
enabled: true,
diff --git a/test/notifications/PushRuleVectorState-test.js b/test/notifications/PushRuleVectorState-test.js
deleted file mode 100644
index 1127675791b..00000000000
--- a/test/notifications/PushRuleVectorState-test.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Copyright 2016 OpenMarket Ltd
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-const notifications = require('../../src/notifications');
-
-const prvs = notifications.PushRuleVectorState;
-
-describe("PushRuleVectorState", function() {
- describe("contentRuleVectorStateKind", function() {
- it("should understand normal notifications", function() {
- const rule = {
- actions: [
- "notify",
- ],
- };
-
- expect(prvs.contentRuleVectorStateKind(rule)).
- toEqual(prvs.ON);
- });
-
- it("should handle loud notifications", function() {
- const rule = {
- actions: [
- "notify",
- { set_tweak: "highlight", value: true },
- { set_tweak: "sound", value: "default" },
- ],
- };
-
- expect(prvs.contentRuleVectorStateKind(rule)).
- toEqual(prvs.LOUD);
- });
-
- it("should understand missing highlight.value", function() {
- const rule = {
- actions: [
- "notify",
- { set_tweak: "highlight" },
- { set_tweak: "sound", value: "default" },
- ],
- };
-
- expect(prvs.contentRuleVectorStateKind(rule)).
- toEqual(prvs.LOUD);
- });
- });
-});
diff --git a/test/notifications/PushRuleVectorState-test.ts b/test/notifications/PushRuleVectorState-test.ts
new file mode 100644
index 00000000000..031944b84ce
--- /dev/null
+++ b/test/notifications/PushRuleVectorState-test.ts
@@ -0,0 +1,75 @@
+/*
+Copyright 2016 OpenMarket Ltd
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import {
+ PushRuleActionName,
+ TweakHighlight,
+ TweakName,
+ TweakSound,
+} from "matrix-js-sdk/src/matrix";
+
+import { PushRuleVectorState } from "../../src/notifications";
+
+describe("PushRuleVectorState", function() {
+ describe("contentRuleVectorStateKind", function() {
+ it("should understand normal notifications", function() {
+ const rule = {
+ actions: [
+ PushRuleActionName.Notify,
+ ],
+ default: false,
+ enabled: false,
+ rule_id: '1',
+ };
+
+ expect(PushRuleVectorState.contentRuleVectorStateKind(rule)).
+ toEqual(PushRuleVectorState.ON);
+ });
+
+ it("should handle loud notifications", function() {
+ const rule = {
+ actions: [
+ PushRuleActionName.Notify,
+ { set_tweak: TweakName.Highlight, value: true } as TweakHighlight,
+ { set_tweak: TweakName.Sound, value: "default" } as TweakSound,
+ ],
+ default: false,
+ enabled: false,
+ rule_id: '1',
+ };
+
+ expect(PushRuleVectorState.contentRuleVectorStateKind(rule)).
+ toEqual(PushRuleVectorState.LOUD);
+ });
+
+ it("should understand missing highlight.value", function() {
+ const rule = {
+ actions: [
+ PushRuleActionName.Notify,
+ { set_tweak: TweakName.Highlight } as TweakHighlight,
+ { set_tweak: TweakName.Sound, value: "default" } as TweakSound,
+ ],
+ default: false,
+ enabled: false,
+ rule_id: '1',
+ };
+
+ expect(PushRuleVectorState.contentRuleVectorStateKind(rule)).
+ toEqual(PushRuleVectorState.LOUD);
+ });
+ });
+});
diff --git a/test/stores/VideoChannelStore-test.ts b/test/stores/VideoChannelStore-test.ts
new file mode 100644
index 00000000000..e1420195c17
--- /dev/null
+++ b/test/stores/VideoChannelStore-test.ts
@@ -0,0 +1,83 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import { ClientWidgetApi, MatrixWidgetType } from "matrix-widget-api";
+
+import "../skinned-sdk";
+import { stubClient, mkRoom } from "../test-utils";
+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 VideoChannelStore, { VideoChannelEvent } from "../../src/stores/VideoChannelStore";
+import { VIDEO_CHANNEL } from "../../src/utils/VideoChannelUtils";
+
+describe("VideoChannelStore", () => {
+ stubClient();
+ mkRoom(MatrixClientPeg.get(), "!1:example.org");
+
+ const videoStore = VideoChannelStore.instance;
+ const widgetStore = ActiveWidgetStore.instance;
+
+ jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([{
+ id: VIDEO_CHANNEL,
+ eventId: "$1:example.org",
+ roomId: "!1:example.org",
+ type: MatrixWidgetType.JitsiMeet,
+ url: "",
+ name: "Video channel",
+ creatorUserId: "@alice:example.org",
+ avatar_url: null,
+ }]);
+ jest.spyOn(WidgetMessagingStore.instance, "getMessagingForUid").mockReturnValue({
+ on: () => {},
+ off: () => {},
+ once: () => {},
+ transport: {
+ send: () => {},
+ reply: () => {},
+ },
+ } as unknown as ClientWidgetApi);
+
+ beforeEach(() => {
+ videoStore.start();
+ });
+
+ afterEach(() => {
+ videoStore.stop();
+ jest.clearAllMocks();
+ });
+
+ it("tracks connection state", async () => {
+ expect(videoStore.roomId).toBeFalsy();
+
+ const waitForConnect = new Promise(resolve =>
+ videoStore.once(VideoChannelEvent.Connect, resolve),
+ );
+ widgetStore.setWidgetPersistence(VIDEO_CHANNEL, "!1:example.org", true);
+ await waitForConnect;
+
+ expect(videoStore.roomId).toEqual("!1:example.org");
+
+ const waitForDisconnect = new Promise(resolve =>
+ videoStore.once(VideoChannelEvent.Disconnect, resolve),
+ );
+ widgetStore.setWidgetPersistence(VIDEO_CHANNEL, "!1:example.org", false);
+ await waitForDisconnect;
+
+ expect(videoStore.roomId).toBeFalsy();
+ });
+});
diff --git a/test/stores/VoiceChannelStore-test.ts b/test/stores/VoiceChannelStore-test.ts
deleted file mode 100644
index cf70e7314c5..00000000000
--- a/test/stores/VoiceChannelStore-test.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-Copyright 2022 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import { ClientWidgetApi, MatrixWidgetType } from "matrix-widget-api";
-
-import "../skinned-sdk";
-import { stubClient } from "../test-utils";
-import WidgetStore from "../../src/stores/WidgetStore";
-import { WidgetMessagingStore } from "../../src/stores/widgets/WidgetMessagingStore";
-import { ElementWidgetActions } from "../../src/stores/widgets/ElementWidgetActions";
-import VoiceChannelStore, { VoiceChannelEvent } from "../../src/stores/VoiceChannelStore";
-import { VOICE_CHANNEL } from "../../src/utils/VoiceChannelUtils";
-
-describe("VoiceChannelStore", () => {
- // Set up mocks to simulate the remote end of the widget API
- let messageSent;
- let messageSendMock;
- let onceMock;
- beforeEach(() => {
- stubClient();
- let resolveMessageSent;
- messageSent = new Promise(resolve => resolveMessageSent = resolve);
- messageSendMock = jest.fn().mockImplementation(() => resolveMessageSent());
- onceMock = jest.fn();
-
- jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([{
- id: VOICE_CHANNEL,
- eventId: "$1:example.org",
- roomId: "!1:example.org",
- type: MatrixWidgetType.JitsiMeet,
- url: "",
- name: "Voice channel",
- creatorUserId: "@alice:example.org",
- avatar_url: null,
- }]);
- jest.spyOn(WidgetMessagingStore.instance, "getMessagingForUid").mockReturnValue({
- on: () => {},
- off: () => {},
- once: onceMock,
- transport: {
- send: messageSendMock,
- reply: () => {},
- },
- } as unknown as ClientWidgetApi);
- });
-
- it("connects and disconnects", async () => {
- const store = VoiceChannelStore.instance;
-
- expect(store.roomId).toBeFalsy();
-
- store.connect("!1:example.org");
- // Wait for the store to contact the widget API
- await messageSent;
- // Then, locate the callback that will confirm the join
- const [, join] = onceMock.mock.calls.find(([action]) =>
- action === `action:${ElementWidgetActions.JoinCall}`,
- );
- // Confirm the join, and wait for the store to update
- const waitForConnect = new Promise(resolve =>
- store.once(VoiceChannelEvent.Connect, resolve),
- );
- join({ detail: {} });
- await waitForConnect;
-
- expect(store.roomId).toEqual("!1:example.org");
-
- store.disconnect();
- // Locate the callback that will perform the hangup
- const [, hangup] = onceMock.mock.calls.find(([action]) =>
- action === `action:${ElementWidgetActions.HangupCall}`,
- );
- // Hangup and wait for the store, once again
- const waitForHangup = new Promise(resolve =>
- store.once(VoiceChannelEvent.Disconnect, resolve),
- );
- hangup({ detail: {} });
- await waitForHangup;
-
- expect(store.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/video.ts b/test/test-utils/video.ts
new file mode 100644
index 00000000000..91309452158
--- /dev/null
+++ b/test/test-utils/video.ts
@@ -0,0 +1,39 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import { EventEmitter } from "events";
+
+import VideoChannelStore, { VideoChannelEvent } from "../../src/stores/VideoChannelStore";
+
+class StubVideoChannelStore extends EventEmitter {
+ private _roomId: string;
+ public get roomId(): string { return this._roomId; }
+
+ public connect = (roomId: string) => {
+ this._roomId = roomId;
+ this.emit(VideoChannelEvent.Connect);
+ };
+ public disconnect = () => {
+ this._roomId = null;
+ this.emit(VideoChannelEvent.Disconnect);
+ };
+}
+
+export const stubVideoChannelStore = (): StubVideoChannelStore => {
+ const store = new StubVideoChannelStore();
+ jest.spyOn(VideoChannelStore, "instance", "get").mockReturnValue(store as unknown as VideoChannelStore);
+ return store;
+};
diff --git a/test/test-utils/voice.ts b/test/test-utils/voice.ts
deleted file mode 100644
index 962e4c6c56b..00000000000
--- a/test/test-utils/voice.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Copyright 2022 The Matrix.org Foundation C.I.C.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-import { EventEmitter } from "events";
-
-import VoiceChannelStore, { VoiceChannelEvent } from "../../src/stores/VoiceChannelStore";
-
-class StubVoiceChannelStore extends EventEmitter {
- private _roomId: string;
- public get roomId(): string { return this._roomId; }
- private _audioMuted: boolean;
- public get audioMuted(): boolean { return this._audioMuted; }
- private _videoMuted: boolean;
- public get videoMuted(): boolean { return this._videoMuted; }
-
- public connect = jest.fn().mockImplementation(async (roomId: string) => {
- this._roomId = roomId;
- this._audioMuted = true;
- this._videoMuted = true;
- this.emit(VoiceChannelEvent.Connect);
- });
- public disconnect = jest.fn().mockImplementation(async () => {
- this._roomId = null;
- this.emit(VoiceChannelEvent.Disconnect);
- });
- public muteAudio = jest.fn().mockImplementation(async () => {
- this._audioMuted = true;
- this.emit(VoiceChannelEvent.MuteAudio);
- });
- public unmuteAudio = jest.fn().mockImplementation(async () => {
- this._audioMuted = false;
- this.emit(VoiceChannelEvent.UnmuteAudio);
- });
- public muteVideo = jest.fn().mockImplementation(async () => {
- this._videoMuted = true;
- this.emit(VoiceChannelEvent.MuteVideo);
- });
- public unmuteVideo = jest.fn().mockImplementation(async () => {
- this._videoMuted = false;
- this.emit(VoiceChannelEvent.UnmuteVideo);
- });
-}
-
-export const stubVoiceChannelStore = () => {
- jest.spyOn(VoiceChannelStore, "instance", "get")
- .mockReturnValue(new StubVoiceChannelStore() as unknown as VoiceChannelStore);
-};