Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit eca8ef3

Browse files
committed
Update thumbnails
Signed-off-by: Šimon Brandner <[email protected]>
1 parent 8f91b04 commit eca8ef3

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/CallHandler.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ export default class CallHandler {
513513
call.placeScreenSharingCall(
514514
remoteElement,
515515
localElement,
516-
async (sources: Array<DesktopCapturerSource>) : Promise<DesktopCapturerSource> => {
517-
const {finished} = Modal.createDialog(DesktopCapturerSourcePicker, {sources});
516+
async () : Promise<DesktopCapturerSource> => {
517+
const {finished} = Modal.createDialog(DesktopCapturerSourcePicker);
518518
const [source] = await finished;
519519
return source;
520520
});

src/components/views/elements/DesktopCapturerSourcePicker.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from 'react';
1818
import { _t } from '../../../languageHandler';
1919
import BaseDialog from "..//dialogs/BaseDialog"
2020
import AccessibleButton from './AccessibleButton';
21+
import {getDesktopCapturerSources} from "matrix-js-sdk/src/webrtc/call";
2122

2223
export enum Tabs {
2324
Screens = "screens",
@@ -56,24 +57,37 @@ export class ExistingSource extends React.Component<DesktopCapturerSourceIProps>
5657

5758
export interface DesktopCapturerSourcePickerIState {
5859
selectedTab: Tabs;
60+
sources: Array<DesktopCapturerSource>;
5961
}
6062
export interface DesktopCapturerSourcePickerIProps {
61-
sources: Array<DesktopCapturerSource>;
6263
onFinished(source: DesktopCapturerSource): void;
6364
}
6465

65-
// TODO: Figure out a way to update sources for live preview
66-
6766
export default class DesktopCapturerSourcePicker extends React.Component<
6867
DesktopCapturerSourcePickerIProps,
6968
DesktopCapturerSourcePickerIState
7069
> {
70+
interval;
71+
7172
constructor(props) {
7273
super(props);
7374

7475
this.state = {
7576
selectedTab: Tabs.Screens,
76-
}
77+
sources: [],
78+
};
79+
}
80+
81+
componentDidMount() {
82+
this.interval = setInterval(async () => {
83+
this.setState({
84+
sources: await getDesktopCapturerSources(),
85+
});
86+
}, 500);
87+
}
88+
89+
componentWillUnmount() {
90+
clearInterval(this.interval);
7791
}
7892

7993
onSelect = (source) => {
@@ -95,15 +109,15 @@ export default class DesktopCapturerSourcePicker extends React.Component<
95109
render() {
96110
let sources;
97111
if (this.state.selectedTab === Tabs.Screens) {
98-
sources = this.props.sources
112+
sources = this.state.sources
99113
.filter((source) => {
100114
return source.id.startsWith("screen");
101115
})
102116
.map((source) => {
103117
return <ExistingSource source={source} onSelect={this.onSelect} key={source.id} />;
104118
});
105119
} else {
106-
sources = this.props.sources
120+
sources = this.state.sources
107121
.filter((source) => {
108122
return source.id.startsWith("window");
109123
})

0 commit comments

Comments
 (0)