2018-10-29 17:21:33 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-10-17 11:27:48 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { IStore } from '../../app/types';
|
|
|
|
import { hideDialog } from '../../base/dialog/actions';
|
|
|
|
import { translate } from '../../base/i18n/functions';
|
|
|
|
import { connect } from '../../base/redux/functions';
|
|
|
|
import Dialog from '../../base/ui/components/web/Dialog';
|
2023-02-17 09:34:47 +00:00
|
|
|
import Tabs from '../../base/ui/components/web/Tabs';
|
2022-11-28 10:52:45 +00:00
|
|
|
// eslint-disable-next-line lines-around-comment
|
2022-10-17 11:27:48 +00:00
|
|
|
// @ts-ignore
|
2020-05-20 10:57:03 +00:00
|
|
|
import { obtainDesktopSources } from '../functions';
|
2017-04-06 16:45:36 +00:00
|
|
|
|
2022-10-17 11:27:48 +00:00
|
|
|
// @ts-ignore
|
2017-03-30 16:58:31 +00:00
|
|
|
import DesktopPickerPane from './DesktopPickerPane';
|
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
|
|
|
* The size of the requested thumbnails.
|
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
const THUMBNAIL_SIZE = {
|
2017-03-30 16:58:31 +00:00
|
|
|
height: 300,
|
|
|
|
width: 300
|
|
|
|
};
|
2017-10-20 00:17:38 +00:00
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
|
|
|
* The sources polling interval in ms.
|
|
|
|
*
|
|
|
|
* @type {int}
|
|
|
|
*/
|
2017-10-20 00:17:38 +00:00
|
|
|
const UPDATE_INTERVAL = 2000;
|
2017-04-06 16:45:36 +00:00
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
|
|
|
* The default selected tab.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
const DEFAULT_TAB_TYPE = 'screen';
|
2017-10-20 00:17:38 +00:00
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
const TAB_LABELS = {
|
|
|
|
screen: 'dialog.yourEntireScreen',
|
|
|
|
window: 'dialog.applicationWindow'
|
2017-10-20 00:17:38 +00:00
|
|
|
};
|
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
const VALID_TYPES = Object.keys(TAB_LABELS);
|
2017-03-30 16:58:31 +00:00
|
|
|
|
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of {@link DesktopPicker}.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
interface IProps extends WithTranslation {
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* An array with desktop sharing sources to be displayed.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
desktopSharingSources: Array<string>;
|
2017-10-20 00:17:38 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* Used to request DesktopCapturerSources.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
dispatch: IStore['dispatch'];
|
2017-10-20 00:17:38 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The callback to be invoked when the component is closed or when a
|
|
|
|
* DesktopCapturerSource has been chosen.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
onSourceChoose: Function;
|
|
|
|
}
|
2017-03-30 16:58:31 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} state of {@link DesktopPicker}.
|
|
|
|
*/
|
2022-11-03 08:35:51 +00:00
|
|
|
interface IState {
|
2017-03-30 16:58:31 +00:00
|
|
|
|
2020-04-02 13:18:10 +00:00
|
|
|
/**
|
|
|
|
* The state of the audio screen share checkbox.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
screenShareAudio: boolean;
|
2020-04-02 13:18:10 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* The currently highlighted DesktopCapturerSource.
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
selectedSource: any;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The desktop source type currently being displayed.
|
|
|
|
*/
|
2023-02-17 09:34:47 +00:00
|
|
|
selectedTab: string;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An object containing all the DesktopCapturerSources.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
sources: Object;
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The desktop source types to fetch previews for.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
types: Array<string>;
|
2022-11-03 08:35:51 +00:00
|
|
|
}
|
2018-10-30 05:02:23 +00:00
|
|
|
|
2018-10-29 17:21:33 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* React component for DesktopPicker.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
2022-11-03 08:35:51 +00:00
|
|
|
class DesktopPicker extends PureComponent<IProps, IState> {
|
2018-10-29 17:21:33 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#getDerivedStateFromProps()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
static getDerivedStateFromProps(props: IProps) {
|
2018-10-29 17:21:33 +00:00
|
|
|
return {
|
|
|
|
types: DesktopPicker._getValidTypes(props.desktopSharingSources)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts only the valid types from the passed {@code types}.
|
|
|
|
*
|
|
|
|
* @param {Array<string>} types - The types to filter.
|
|
|
|
* @private
|
|
|
|
* @returns {Array<string>} The filtered types.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
static _getValidTypes(types: string[] = []) {
|
2018-10-29 17:21:33 +00:00
|
|
|
return types.filter(
|
|
|
|
type => VALID_TYPES.includes(type));
|
|
|
|
}
|
|
|
|
|
2022-10-17 11:27:48 +00:00
|
|
|
_poller: any = null;
|
2017-10-06 20:15:51 +00:00
|
|
|
|
2022-11-03 08:35:51 +00:00
|
|
|
state: IState = {
|
2020-04-02 13:18:10 +00:00
|
|
|
screenShareAudio: false,
|
2017-10-06 20:15:51 +00:00
|
|
|
selectedSource: {},
|
2023-02-17 09:34:47 +00:00
|
|
|
selectedTab: DEFAULT_TAB_TYPE,
|
2017-10-20 00:17:38 +00:00
|
|
|
sources: {},
|
|
|
|
types: []
|
2017-10-06 20:15:51 +00:00
|
|
|
};
|
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
|
|
|
* Stores the type of the selected tab.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
_selectedTabType = DEFAULT_TAB_TYPE;
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new DesktopPicker instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
constructor(props: IProps) {
|
2017-03-30 16:58:31 +00:00
|
|
|
super(props);
|
|
|
|
|
2017-10-06 20:15:51 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2017-03-30 16:58:31 +00:00
|
|
|
this._onCloseModal = this._onCloseModal.bind(this);
|
|
|
|
this._onPreviewClick = this._onPreviewClick.bind(this);
|
2020-04-02 13:18:10 +00:00
|
|
|
this._onShareAudioChecked = this._onShareAudioChecked.bind(this);
|
2017-03-30 16:58:31 +00:00
|
|
|
this._onSubmit = this._onSubmit.bind(this);
|
2017-10-27 17:25:28 +00:00
|
|
|
this._onTabSelected = this._onTabSelected.bind(this);
|
2017-03-30 16:58:31 +00:00
|
|
|
this._updateSources = this._updateSources.bind(this);
|
2017-10-20 00:17:38 +00:00
|
|
|
|
|
|
|
this.state.types
|
2018-10-29 17:21:33 +00:00
|
|
|
= DesktopPicker._getValidTypes(this.props.desktopSharingSources);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-20 00:17:38 +00:00
|
|
|
* Starts polling.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
2017-10-20 00:17:38 +00:00
|
|
|
* @returns {void}
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2017-10-20 00:17:38 +00:00
|
|
|
componentDidMount() {
|
2017-03-30 16:58:31 +00:00
|
|
|
this._startPolling();
|
|
|
|
}
|
|
|
|
|
2017-04-06 16:45:36 +00:00
|
|
|
/**
|
|
|
|
* Clean up component and DesktopCapturerSource store state.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._stopPolling();
|
|
|
|
}
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2023-02-17 09:34:47 +00:00
|
|
|
const { selectedTab, selectedSource, sources } = this.state;
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
return (
|
|
|
|
<Dialog
|
2022-10-17 11:27:48 +00:00
|
|
|
ok = {{
|
|
|
|
disabled: Boolean(!this.state.selectedSource.id),
|
|
|
|
translationKey: 'dialog.Share'
|
|
|
|
}}
|
2017-03-30 16:58:31 +00:00
|
|
|
onCancel = { this._onCloseModal }
|
|
|
|
onSubmit = { this._onSubmit }
|
2022-10-17 11:27:48 +00:00
|
|
|
size = 'large'
|
|
|
|
titleKey = 'dialog.shareYourScreen'>
|
2017-03-30 16:58:31 +00:00
|
|
|
{ this._renderTabs() }
|
2023-02-17 09:34:47 +00:00
|
|
|
<DesktopPickerPane
|
|
|
|
key = { selectedTab }
|
|
|
|
onClick = { this._onPreviewClick }
|
|
|
|
onDoubleClick = { this._onSubmit }
|
|
|
|
onShareAudioChecked = { this._onShareAudioChecked }
|
|
|
|
selectedSourceId = { selectedSource.id }
|
|
|
|
sources = { sources[selectedTab as keyof typeof sources] }
|
|
|
|
type = { selectedTab } />
|
2017-04-06 16:45:36 +00:00
|
|
|
</Dialog>
|
|
|
|
);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
2022-10-17 11:27:48 +00:00
|
|
|
* Computes the selected source.
|
2017-10-27 17:25:28 +00:00
|
|
|
*
|
|
|
|
* @param {Object} sources - The available sources.
|
|
|
|
* @returns {Object} The selectedSource value.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
_getSelectedSource(sources: any = {}) {
|
2017-10-27 17:25:28 +00:00
|
|
|
const { selectedSource } = this.state;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If there are no sources for this type (or no sources for any type)
|
|
|
|
* we can't select anything.
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
if (!Array.isArray(sources[this._selectedTabType as keyof typeof sources])
|
|
|
|
|| sources[this._selectedTabType as keyof typeof sources].length <= 0) {
|
2017-10-27 17:25:28 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select the first available source for this type in the following
|
|
|
|
* scenarios:
|
|
|
|
* 1) Nothing is yet selected.
|
|
|
|
* 2) Tab change.
|
|
|
|
* 3) The selected source is no longer available.
|
|
|
|
*/
|
|
|
|
if (!selectedSource // scenario 1)
|
|
|
|
|| selectedSource.type !== this._selectedTabType // scenario 2)
|
|
|
|
|| !sources[this._selectedTabType].some( // scenario 3)
|
2022-10-17 11:27:48 +00:00
|
|
|
(source: any) => source.id === selectedSource.id)) {
|
2017-10-27 17:25:28 +00:00
|
|
|
return {
|
|
|
|
id: sources[this._selectedTabType][0].id,
|
|
|
|
type: this._selectedTabType
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For all other scenarios don't change the selection.
|
|
|
|
*/
|
|
|
|
return selectedSource;
|
|
|
|
}
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2017-04-06 16:45:36 +00:00
|
|
|
* Dispatches an action to hide the DesktopPicker and invokes the passed in
|
2017-07-07 22:45:24 +00:00
|
|
|
* callback with a selectedSource, if any.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
2017-10-06 20:15:51 +00:00
|
|
|
* @param {string} [id] - The id of the DesktopCapturerSource to pass into
|
|
|
|
* the onSourceChoose callback.
|
2017-07-07 22:45:24 +00:00
|
|
|
* @param {string} type - The type of the DesktopCapturerSource to pass into
|
|
|
|
* the onSourceChoose callback.
|
2020-04-02 13:18:10 +00:00
|
|
|
* @param {boolean} screenShareAudio - Whether or not to add system audio to
|
|
|
|
* screen sharing session.
|
2017-03-30 16:58:31 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
_onCloseModal(id = '', type?: string, screenShareAudio = false) {
|
2020-04-02 13:18:10 +00:00
|
|
|
this.props.onSourceChoose(id, type, screenShareAudio);
|
2017-04-06 16:45:36 +00:00
|
|
|
this.props.dispatch(hideDialog());
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-06 16:45:36 +00:00
|
|
|
* Sets the currently selected DesktopCapturerSource.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
2017-04-06 16:45:36 +00:00
|
|
|
* @param {string} id - The id of DesktopCapturerSource.
|
2017-07-07 22:45:24 +00:00
|
|
|
* @param {string} type - The type of DesktopCapturerSource.
|
2017-03-30 16:58:31 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
_onPreviewClick(id: string, type: string) {
|
2017-07-07 22:45:24 +00:00
|
|
|
this.setState({
|
|
|
|
selectedSource: {
|
|
|
|
id,
|
|
|
|
type
|
|
|
|
}
|
|
|
|
});
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-06 16:45:36 +00:00
|
|
|
* Request to close the modal and execute callbacks with the selected source
|
|
|
|
* id.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
_onSubmit() {
|
2020-04-02 13:18:10 +00:00
|
|
|
const { selectedSource: { id, type }, screenShareAudio } = this.state;
|
2017-07-07 22:45:24 +00:00
|
|
|
|
2020-04-02 13:18:10 +00:00
|
|
|
this._onCloseModal(id, type, screenShareAudio);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
/**
|
|
|
|
* Stores the selected tab and updates the selected source via
|
|
|
|
* {@code _getSelectedSource}.
|
|
|
|
*
|
2023-02-17 09:34:47 +00:00
|
|
|
* @param {string} id - The id of the newly selected tab.
|
2017-10-27 17:25:28 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-02-17 09:34:47 +00:00
|
|
|
_onTabSelected(id: string) {
|
|
|
|
const { sources } = this.state;
|
2017-10-27 17:25:28 +00:00
|
|
|
|
2023-02-17 09:34:47 +00:00
|
|
|
this._selectedTabType = id;
|
2020-04-02 13:18:10 +00:00
|
|
|
|
|
|
|
// When we change tabs also reset the screenShareAudio state so we don't
|
|
|
|
// use the option from one tab when sharing from another.
|
2017-10-27 17:25:28 +00:00
|
|
|
this.setState({
|
2020-04-02 13:18:10 +00:00
|
|
|
screenShareAudio: false,
|
2018-09-05 21:46:28 +00:00
|
|
|
selectedSource: this._getSelectedSource(sources),
|
2023-02-17 09:34:47 +00:00
|
|
|
selectedTab: id
|
2017-10-27 17:25:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-02 13:18:10 +00:00
|
|
|
/**
|
|
|
|
* Set the screenSharingAudio state indicating whether or not to also share
|
|
|
|
* system audio.
|
|
|
|
*
|
|
|
|
* @param {boolean} checked - Share audio or not.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-10-17 11:27:48 +00:00
|
|
|
_onShareAudioChecked(checked: boolean) {
|
2020-04-02 13:18:10 +00:00
|
|
|
this.setState({ screenShareAudio: checked });
|
|
|
|
}
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2017-04-06 16:45:36 +00:00
|
|
|
* Configures and renders the tabs for display.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
2017-04-06 16:45:36 +00:00
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
_renderTabs() {
|
2023-02-17 09:34:47 +00:00
|
|
|
const { types } = this.state;
|
2017-10-20 00:17:38 +00:00
|
|
|
const { t } = this.props;
|
2017-04-06 16:45:36 +00:00
|
|
|
const tabs
|
2017-10-20 00:17:38 +00:00
|
|
|
= types.map(
|
|
|
|
type => {
|
2017-07-09 21:34:08 +00:00
|
|
|
return {
|
2023-02-17 09:34:47 +00:00
|
|
|
accessibilityLabel: t(TAB_LABELS[type as keyof typeof TAB_LABELS]),
|
|
|
|
id: type,
|
2022-10-17 11:27:48 +00:00
|
|
|
label: t(TAB_LABELS[type as keyof typeof TAB_LABELS])
|
2017-07-09 21:34:08 +00:00
|
|
|
};
|
|
|
|
});
|
2017-04-06 16:45:36 +00:00
|
|
|
|
2017-10-27 17:25:28 +00:00
|
|
|
return (
|
|
|
|
<Tabs
|
2023-02-17 09:34:47 +00:00
|
|
|
accessibilityLabel = ''
|
|
|
|
className = 'desktop-picker-tabs-container'
|
|
|
|
onChange = { this._onTabSelected }
|
2018-09-05 21:46:28 +00:00
|
|
|
selected = { this.state.selectedTab }
|
2017-10-27 17:25:28 +00:00
|
|
|
tabs = { tabs } />);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Create an interval to update known available DesktopCapturerSources.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
2017-04-06 16:45:36 +00:00
|
|
|
* @private
|
2017-03-30 16:58:31 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
_startPolling() {
|
|
|
|
this._stopPolling();
|
2017-10-20 00:17:38 +00:00
|
|
|
this._updateSources();
|
2017-04-06 16:45:36 +00:00
|
|
|
this._poller = window.setInterval(this._updateSources, UPDATE_INTERVAL);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-06 16:45:36 +00:00
|
|
|
* Cancels the interval to update DesktopCapturerSources.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
2017-04-06 16:45:36 +00:00
|
|
|
* @private
|
2017-03-30 16:58:31 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
_stopPolling() {
|
|
|
|
window.clearInterval(this._poller);
|
|
|
|
this._poller = null;
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-27 17:25:28 +00:00
|
|
|
* Obtains the desktop sources and updates state with them.
|
2017-03-30 16:58:31 +00:00
|
|
|
*
|
|
|
|
* @private
|
2017-04-06 16:45:36 +00:00
|
|
|
* @returns {void}
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2017-04-06 16:45:36 +00:00
|
|
|
_updateSources() {
|
2017-10-20 00:17:38 +00:00
|
|
|
const { types } = this.state;
|
|
|
|
|
|
|
|
if (types.length > 0) {
|
|
|
|
obtainDesktopSources(
|
|
|
|
this.state.types,
|
|
|
|
{ thumbnailSize: THUMBNAIL_SIZE }
|
|
|
|
)
|
2022-10-17 11:27:48 +00:00
|
|
|
.then((sources: any) => {
|
2017-10-27 17:25:28 +00:00
|
|
|
const selectedSource = this._getSelectedSource(sources);
|
2017-03-30 16:58:31 +00:00
|
|
|
|
2017-10-20 00:17:38 +00:00
|
|
|
// TODO: Maybe check if we have stopped the timer and unmounted
|
|
|
|
// the component.
|
2017-10-27 17:25:28 +00:00
|
|
|
this.setState({
|
|
|
|
sources,
|
|
|
|
selectedSource
|
|
|
|
});
|
2017-10-20 00:17:38 +00:00
|
|
|
})
|
|
|
|
.catch(() => { /* ignore */ });
|
|
|
|
}
|
|
|
|
}
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 00:17:38 +00:00
|
|
|
export default translate(connect()(DesktopPicker));
|