Update thumbnails

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-01-14 12:44:48 +01:00
parent 8f91b04eb3
commit eca8ef3b35
No known key found for this signature in database
GPG Key ID: 9760693FDD98A790
2 changed files with 22 additions and 8 deletions

View File

@ -513,8 +513,8 @@ export default class CallHandler {
call.placeScreenSharingCall( call.placeScreenSharingCall(
remoteElement, remoteElement,
localElement, localElement,
async (sources: Array<DesktopCapturerSource>) : Promise<DesktopCapturerSource> => { async () : Promise<DesktopCapturerSource> => {
const {finished} = Modal.createDialog(DesktopCapturerSourcePicker, {sources}); const {finished} = Modal.createDialog(DesktopCapturerSourcePicker);
const [source] = await finished; const [source] = await finished;
return source; return source;
}); });

View File

@ -18,6 +18,7 @@ import React from 'react';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import BaseDialog from "..//dialogs/BaseDialog" import BaseDialog from "..//dialogs/BaseDialog"
import AccessibleButton from './AccessibleButton'; import AccessibleButton from './AccessibleButton';
import {getDesktopCapturerSources} from "matrix-js-sdk/src/webrtc/call";
export enum Tabs { export enum Tabs {
Screens = "screens", Screens = "screens",
@ -56,24 +57,37 @@ export class ExistingSource extends React.Component<DesktopCapturerSourceIProps>
export interface DesktopCapturerSourcePickerIState { export interface DesktopCapturerSourcePickerIState {
selectedTab: Tabs; selectedTab: Tabs;
sources: Array<DesktopCapturerSource>;
} }
export interface DesktopCapturerSourcePickerIProps { export interface DesktopCapturerSourcePickerIProps {
sources: Array<DesktopCapturerSource>;
onFinished(source: DesktopCapturerSource): void; onFinished(source: DesktopCapturerSource): void;
} }
// TODO: Figure out a way to update sources for live preview
export default class DesktopCapturerSourcePicker extends React.Component< export default class DesktopCapturerSourcePicker extends React.Component<
DesktopCapturerSourcePickerIProps, DesktopCapturerSourcePickerIProps,
DesktopCapturerSourcePickerIState DesktopCapturerSourcePickerIState
> { > {
interval;
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
selectedTab: Tabs.Screens, selectedTab: Tabs.Screens,
sources: [],
};
} }
componentDidMount() {
this.interval = setInterval(async () => {
this.setState({
sources: await getDesktopCapturerSources(),
});
}, 500);
}
componentWillUnmount() {
clearInterval(this.interval);
} }
onSelect = (source) => { onSelect = (source) => {
@ -95,7 +109,7 @@ export default class DesktopCapturerSourcePicker extends React.Component<
render() { render() {
let sources; let sources;
if (this.state.selectedTab === Tabs.Screens) { if (this.state.selectedTab === Tabs.Screens) {
sources = this.props.sources sources = this.state.sources
.filter((source) => { .filter((source) => {
return source.id.startsWith("screen"); return source.id.startsWith("screen");
}) })
@ -103,7 +117,7 @@ export default class DesktopCapturerSourcePicker extends React.Component<
return <ExistingSource source={source} onSelect={this.onSelect} key={source.id} />; return <ExistingSource source={source} onSelect={this.onSelect} key={source.id} />;
}); });
} else { } else {
sources = this.props.sources sources = this.state.sources
.filter((source) => { .filter((source) => {
return source.id.startsWith("window"); return source.id.startsWith("window");
}) })