diff --git a/src/components/views/elements/DesktopCapturerSourcePicker.tsx b/src/components/views/elements/DesktopCapturerSourcePicker.tsx index 8b7eaca7ea..49a2bda1f7 100644 --- a/src/components/views/elements/DesktopCapturerSourcePicker.tsx +++ b/src/components/views/elements/DesktopCapturerSourcePicker.tsx @@ -22,6 +22,7 @@ import classNames from 'classnames'; import AccessibleButton from './AccessibleButton'; import { getDesktopCapturerSources } from "matrix-js-sdk/src/webrtc/call"; import { replaceableComponent } from "../../../utils/replaceableComponent"; +import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView'; export interface DesktopCapturerSource { id: string; @@ -41,11 +42,11 @@ export interface ExistingSourceIProps { } export class ExistingSource extends React.Component { - constructor(props) { + constructor(props: ExistingSourceIProps) { super(props); } - onClick = (ev) => { + private onClick = (): void => { this.props.onSelect(this.props.source); }; @@ -59,7 +60,8 @@ export class ExistingSource extends React.Component { + onClick={this.onClick} + > { - interval; +> { + interval: number; - constructor(props) { + constructor(props: PickerIProps) { super(props); this.state = { @@ -116,39 +118,24 @@ export default class DesktopCapturerSourcePicker extends React.Component< clearInterval(this.interval); } - onSelect = (source) => { + private onSelect = (source: DesktopCapturerSource): void => { this.setState({ selectedSource: source }); }; - onShare = () => { + private onShare = (): void => { this.props.onFinished(this.state.selectedSource); }; - onScreensClick = () => { - if (this.state.selectedTab === Tabs.Screens) return; - this.setState({ - selectedTab: Tabs.Screens, - selectedSource: null, - }); + private onTabChange = (): void => { + this.setState({ selectedSource: null }); }; - onWindowsClick = () => { - if (this.state.selectedTab === Tabs.Windows) return; - this.setState({ - selectedTab: Tabs.Windows, - selectedSource: null, - }); - }; - - onCloseClick = () => { + private onCloseClick = (): void => { this.props.onFinished(null); }; - render() { - const sources = this.state.sources.filter((source) => { - return source.id.startsWith(this.state.selectedTab); - }); - const sourceElements = sources.map((source) => { + private getTab(type: "screen" | "window", label: string): Tab { + const sources = this.state.sources.filter((source) => source.id.startsWith(type)).map((source) => { return ( + { sources } + + )); + } + + render() { + const tabs = [ + this.getTab("screen", _t("Share entire screen")), + this.getTab("window", _t("Application window")), + ]; return ( -
- - {_t("Screens")} - - - {_t("Windows")} - -
-
- { sourceElements } -
+