mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-18 18:59:23 +00:00
allow join unmuted in widget mode
This commit is contained in:
@@ -156,8 +156,14 @@ describe("useMuteStates", () => {
|
|||||||
expect(screen.getByTestId("video-enabled").textContent).toBe("false");
|
expect(screen.getByTestId("video-enabled").textContent).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skipLobby mutes inputs", () => {
|
it("skipLobby mutes inputs on SPA", () => {
|
||||||
mockConfig();
|
mockConfig();
|
||||||
|
vi.mock("../widget", () => {
|
||||||
|
return {
|
||||||
|
widget: null,
|
||||||
|
ElementWidgetActions: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<MemoryRouter initialEntries={["/room/?skipLobby=true"]}>
|
<MemoryRouter initialEntries={["/room/?skipLobby=true"]}>
|
||||||
@@ -169,4 +175,31 @@ describe("useMuteStates", () => {
|
|||||||
expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
|
expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
|
||||||
expect(screen.getByTestId("video-enabled").textContent).toBe("false");
|
expect(screen.getByTestId("video-enabled").textContent).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skipLobby does not mute inputs in widget mode", () => {
|
||||||
|
mockConfig();
|
||||||
|
vi.mock("../widget", () => {
|
||||||
|
return {
|
||||||
|
widget: {
|
||||||
|
api: {
|
||||||
|
transport: {
|
||||||
|
send: async (): Promise<void> => new Promise((r) => r()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lazyActions: { on: vi.fn(), off: vi.fn() },
|
||||||
|
},
|
||||||
|
ElementWidgetActions: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
render(
|
||||||
|
<MemoryRouter initialEntries={["/room/?skipLobby=true"]}>
|
||||||
|
<MediaDevicesContext.Provider value={mockMediaDevices()}>
|
||||||
|
<TestComponent />
|
||||||
|
</MediaDevicesContext.Provider>
|
||||||
|
</MemoryRouter>,
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId("audio-enabled").textContent).toBe("true");
|
||||||
|
expect(screen.getByTestId("video-enabled").textContent).toBe("true");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,13 +74,14 @@ export function useMuteStates(): MuteStates {
|
|||||||
const devices = useMediaDevices();
|
const devices = useMediaDevices();
|
||||||
|
|
||||||
const { skipLobby } = useUrlParams();
|
const { skipLobby } = useUrlParams();
|
||||||
|
// In SPA without lobby we need to protect from unmuted joins (Privacy).
|
||||||
|
const allowStartUnmuted = !skipLobby || widget !== null;
|
||||||
const audio = useMuteState(devices.audioInput, () => {
|
const audio = useMuteState(devices.audioInput, () => {
|
||||||
return Config.get().media_devices.enable_audio && !skipLobby;
|
return Config.get().media_devices.enable_audio && allowStartUnmuted;
|
||||||
});
|
});
|
||||||
const video = useMuteState(
|
const video = useMuteState(
|
||||||
devices.videoInput,
|
devices.videoInput,
|
||||||
() => Config.get().media_devices.enable_video && !skipLobby,
|
() => Config.get().media_devices.enable_video && allowStartUnmuted,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user