|
|
@@ -85,7 +85,7 @@ class DesktopPicker extends Component {
|
|
85
|
85
|
super(props);
|
|
86
|
86
|
|
|
87
|
87
|
this.state = {
|
|
88
|
|
- selectedSourceId: ''
|
|
|
88
|
+ selectedSource: {}
|
|
89
|
89
|
};
|
|
90
|
90
|
|
|
91
|
91
|
this._poller = null;
|
|
|
@@ -116,10 +116,13 @@ class DesktopPicker extends Component {
|
|
116
|
116
|
* @returns {void}
|
|
117
|
117
|
*/
|
|
118
|
118
|
componentWillReceiveProps(nextProps) {
|
|
119
|
|
- if (!this.state.selectedSourceId
|
|
|
119
|
+ if (!this.state.selectedSource.id
|
|
120
|
120
|
&& nextProps.sources.screen.length) {
|
|
121
|
121
|
this.setState({
|
|
122
|
|
- selectedSourceId: nextProps.sources.screen[0].id
|
|
|
122
|
+ selectedSource: {
|
|
|
123
|
+ id: nextProps.sources.screen[0].id,
|
|
|
124
|
+ type: 'screen'
|
|
|
125
|
+ }
|
|
123
|
126
|
});
|
|
124
|
127
|
}
|
|
125
|
128
|
}
|
|
|
@@ -155,14 +158,16 @@ class DesktopPicker extends Component {
|
|
155
|
158
|
|
|
156
|
159
|
/**
|
|
157
|
160
|
* Dispatches an action to hide the DesktopPicker and invokes the passed in
|
|
158
|
|
- * callback with a selectedSourceId, if any.
|
|
|
161
|
+ * callback with a selectedSource, if any.
|
|
159
|
162
|
*
|
|
160
|
163
|
* @param {string} id - The id of the DesktopCapturerSource to pass into the
|
|
161
|
164
|
* onSourceChoose callback.
|
|
|
165
|
+ * @param {string} type - The type of the DesktopCapturerSource to pass into
|
|
|
166
|
+ * the onSourceChoose callback.
|
|
162
|
167
|
* @returns {void}
|
|
163
|
168
|
*/
|
|
164
|
|
- _onCloseModal(id = '') {
|
|
165
|
|
- this.props.onSourceChoose(id);
|
|
|
169
|
+ _onCloseModal(id, type) {
|
|
|
170
|
+ this.props.onSourceChoose(id, type);
|
|
166
|
171
|
this.props.dispatch(hideDialog());
|
|
167
|
172
|
}
|
|
168
|
173
|
|
|
|
@@ -170,10 +175,16 @@ class DesktopPicker extends Component {
|
|
170
|
175
|
* Sets the currently selected DesktopCapturerSource.
|
|
171
|
176
|
*
|
|
172
|
177
|
* @param {string} id - The id of DesktopCapturerSource.
|
|
|
178
|
+ * @param {string} type - The type of DesktopCapturerSource.
|
|
173
|
179
|
* @returns {void}
|
|
174
|
180
|
*/
|
|
175
|
|
- _onPreviewClick(id) {
|
|
176
|
|
- this.setState({ selectedSourceId: id });
|
|
|
181
|
+ _onPreviewClick(id, type) {
|
|
|
182
|
+ this.setState({
|
|
|
183
|
+ selectedSource: {
|
|
|
184
|
+ id,
|
|
|
185
|
+ type
|
|
|
186
|
+ }
|
|
|
187
|
+ });
|
|
177
|
188
|
}
|
|
178
|
189
|
|
|
179
|
190
|
/**
|
|
|
@@ -183,7 +194,9 @@ class DesktopPicker extends Component {
|
|
183
|
194
|
* @returns {void}
|
|
184
|
195
|
*/
|
|
185
|
196
|
_onSubmit() {
|
|
186
|
|
- this._onCloseModal(this.state.selectedSourceId);
|
|
|
197
|
+ const { id, type } = this.state.selectedSource;
|
|
|
198
|
+
|
|
|
199
|
+ this._onCloseModal(id, type);
|
|
187
|
200
|
}
|
|
188
|
201
|
|
|
189
|
202
|
/**
|
|
|
@@ -193,7 +206,7 @@ class DesktopPicker extends Component {
|
|
193
|
206
|
* @returns {ReactElement}
|
|
194
|
207
|
*/
|
|
195
|
208
|
_renderTabs() {
|
|
196
|
|
- const { selectedSourceId } = this.state;
|
|
|
209
|
+ const { selectedSource } = this.state;
|
|
197
|
210
|
const { sources, t } = this.props;
|
|
198
|
211
|
const tabs
|
|
199
|
212
|
= TABS_TO_POPULATE.map(({ defaultSelected, label, type }) => {
|
|
|
@@ -202,7 +215,7 @@ class DesktopPicker extends Component {
|
|
202
|
215
|
key = { type }
|
|
203
|
216
|
onClick = { this._onPreviewClick }
|
|
204
|
217
|
onDoubleClick = { this._onCloseModal }
|
|
205
|
|
- selectedSourceId = { selectedSourceId }
|
|
|
218
|
+ selectedSourceId = { selectedSource.id }
|
|
206
|
219
|
sources = { sources[type] || [] }
|
|
207
|
220
|
type = { type } />,
|
|
208
|
221
|
defaultSelected,
|