diff --git a/res/css/views/voip/_LegacyCallPreview.pcss b/res/css/views/voip/_LegacyCallPreview.pcss index 86d6fae0d4..01a8874604 100644 --- a/res/css/views/voip/_LegacyCallPreview.pcss +++ b/res/css/views/voip/_LegacyCallPreview.pcss @@ -15,8 +15,12 @@ limitations under the License. */ .mx_LegacyCallPreview { - position: fixed; + align-items: flex-end; + display: flex; + flex-direction: column; + gap: $spacing-16; left: 0; + position: fixed; top: 0; pointer-events: initial; /* restore pointer events so the user can leave/interact */ diff --git a/src/components/views/voip/PictureInPictureDragger.tsx b/src/components/views/voip/PictureInPictureDragger.tsx index 58a7a56493..3ba2c4ab53 100644 --- a/src/components/views/voip/PictureInPictureDragger.tsx +++ b/src/components/views/voip/PictureInPictureDragger.tsx @@ -47,7 +47,7 @@ interface IChildrenOptions { interface IProps { className?: string; - children: CreatePipChildren; + children: Array; draggable: boolean; onDoubleClick?: () => void; onMove?: () => void; @@ -208,6 +208,13 @@ export default class PictureInPictureDragger extends React.Component { transform: `translateX(${this.translationX}px) translateY(${this.translationY}px)`, }; + const children = this.props.children.map((create: CreatePipChildren) => { + return create({ + onStartMoving: this.onStartMoving, + onResize: this.onResize, + }); + }); + return ( ); } diff --git a/src/components/views/voip/PipView.tsx b/src/components/views/voip/PipView.tsx index 8f586b9eda..b8940f3209 100644 --- a/src/components/views/voip/PipView.tsx +++ b/src/components/views/voip/PipView.tsx @@ -373,24 +373,20 @@ class PipView extends React.Component { public render() { const pipMode = true; - let pipContent: CreatePipChildren | null = null; - - if (this.props.voiceBroadcastPlayback) { - pipContent = this.createVoiceBroadcastPlaybackPipContent(this.props.voiceBroadcastPlayback); - } - - if (this.props.voiceBroadcastPreRecording) { - pipContent = this.createVoiceBroadcastPreRecordingPipContent(this.props.voiceBroadcastPreRecording); - } + let pipContent: Array = []; if (this.props.voiceBroadcastRecording) { - pipContent = this.createVoiceBroadcastRecordingPipContent(this.props.voiceBroadcastRecording); + pipContent = [this.createVoiceBroadcastRecordingPipContent(this.props.voiceBroadcastRecording)]; + } else if (this.props.voiceBroadcastPreRecording) { + pipContent = [this.createVoiceBroadcastPreRecordingPipContent(this.props.voiceBroadcastPreRecording)]; + } else if (this.props.voiceBroadcastPlayback) { + pipContent = [this.createVoiceBroadcastPlaybackPipContent(this.props.voiceBroadcastPlayback)]; } if (this.state.primaryCall) { // get a ref to call inside the current scope const call = this.state.primaryCall; - pipContent = ({ onStartMoving, onResize }) => ( + pipContent.push(({ onStartMoving, onResize }) => ( { pipMode={pipMode} onResize={onResize} /> - ); + )); } if (this.state.showWidgetInPip) { @@ -412,7 +408,7 @@ class PipView extends React.Component { const viewingCallRoom = this.state.viewedRoomId === roomId; const isCall = CallStore.instance.getActiveCall(roomId) !== null; - pipContent = ({ onStartMoving }) => ( + pipContent.push(({ onStartMoving }) => (
{ @@ -432,10 +428,10 @@ class PipView extends React.Component { movePersistedElement={this.movePersistedElement} />
- ); + )); } - if (!!pipContent) { + if (pipContent.length) { return ( { let renderResult: RenderResult; - const mkContent1: CreatePipChildren = () => { - return
content 1
; - }; + const mkContent1: Array = [ + () => { + return
content 1
; + }, + ]; - const mkContent2: CreatePipChildren = () => { - return ( -
- content 2
- content 2.2 -
- ); - }; + const mkContent2: Array = [ + () => { + return ( +
+ content 2
+ content 2.2 +
+ ); + }, + ]; describe("when rendering the dragger with PiP content 1", () => { beforeEach(() => { @@ -66,4 +70,16 @@ describe("PictureInPictureDragger", () => { }); }); }); + + describe("when rendering the dragger with PiP content 1 and 2", () => { + beforeEach(() => { + renderResult = render( + {[...mkContent1, ...mkContent2]}, + ); + }); + + it("should render both contents", () => { + expect(renderResult.container).toMatchSnapshot(); + }); + }); }); diff --git a/test/components/views/voip/PipView-test.tsx b/test/components/views/voip/PipView-test.tsx index 78481112fe..4d15116f96 100644 --- a/test/components/views/voip/PipView-test.tsx +++ b/test/components/views/voip/PipView-test.tsx @@ -279,9 +279,18 @@ describe("PipView", () => { }); it("should render the voice broadcast recording PiP", () => { - // check for the „Live“ badge + // check for the „Live“ badge to be present expect(screen.queryByText("Live")).toBeInTheDocument(); }); + + it("and a call it should show both, the call and the recording", async () => { + await withCall(async () => { + // Broadcast: Check for the „Live“ badge to be present + expect(screen.queryByText("Live")).toBeInTheDocument(); + // Call: Check for the „Fill screen“ button to be present + expect(screen.queryByLabelText("Fill screen")).toBeInTheDocument(); + }); + }); }); describe("when there is a voice broadcast playback and pre-recording", () => { diff --git a/test/components/views/voip/__snapshots__/PictureInPictureDragger-test.tsx.snap b/test/components/views/voip/__snapshots__/PictureInPictureDragger-test.tsx.snap index 7996519485..0e382ea7f0 100644 --- a/test/components/views/voip/__snapshots__/PictureInPictureDragger-test.tsx.snap +++ b/test/components/views/voip/__snapshots__/PictureInPictureDragger-test.tsx.snap @@ -1,5 +1,22 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`PictureInPictureDragger when rendering the dragger with PiP content 1 and 2 should render both contents 1`] = ` +
+ +
+`; + exports[`PictureInPictureDragger when rendering the dragger with PiP content 1 and rendering PiP content 2 should update the PiP content 1`] = `