Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(config): Document desktopSharingSources and improve types

Hristo Terezov35554533d1e4
diff --git a/config.js b/config.js
index 81b9eedb4e..a33de883ec 100644
--- a/config.js
+++ b/config.js
@@ -1631,6 +1631,9 @@ var config = {
// video: true
// },
// },
+ // The default type of desktop sharing sources that will be used in the electron app.
+ // desktopSharingSources: ['screen', 'window'],
+
// Disables the echo cancelation for local audio tracks.
// disableAEC: true,
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 89c8d0b8d6..6fab85965b 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -1,5 +1,6 @@
import { ToolbarButton } from '../../toolbox/types';
import { ILoggingConfig } from '../logging/types';
+import { DesktopSharingSourceType } from '../tracks/types';
type ButtonsWithNotifyClick = 'camera' |
'chat' |
@@ -280,6 +281,7 @@ export interface IConfig {
max?: number;
min?: number;
};
+ desktopSharingSources?: Array<DesktopSharingSourceType>;
dialInConfCodeUrl?: string;
dialInNumbersUrl?: string;
dialOutAuthUrl?: string;
diff --git a/react/features/base/tracks/types.ts b/react/features/base/tracks/types.ts
index 18a990d159..f5f5ce2885 100644
--- a/react/features/base/tracks/types.ts
+++ b/react/features/base/tracks/types.ts
@@ -12,7 +12,7 @@ export interface ITrackOptions {
};
};
desktopSharingSourceDevice?: string;
- desktopSharingSources?: string[];
+ desktopSharingSources?: Array<DesktopSharingSourceType>;
devices?: string[];
facingMode?: string;
micDeviceId?: string | null;
@@ -67,9 +67,11 @@ export interface IToggleScreenSharingOptions {
shareOptions: IShareOptions;
}
+export type DesktopSharingSourceType = 'screen' | 'window';
+
export interface IShareOptions {
desktopSharingSourceDevice?: string;
- desktopSharingSources?: string[];
+ desktopSharingSources?: Array<DesktopSharingSourceType>;
desktopStream?: any;
}
diff --git a/react/features/desktop-picker/actions.ts b/react/features/desktop-picker/actions.ts
index c6e647209e..7b7b89b500 100644
--- a/react/features/desktop-picker/actions.ts
+++ b/react/features/desktop-picker/actions.ts
@@ -1,7 +1,12 @@
import { openDialog } from '../base/dialog/actions';
+import { DesktopSharingSourceType } from '../base/tracks/types';
import DesktopPicker from './components/DesktopPicker';
+type Options = {
+ desktopSharingSources?: Array<DesktopSharingSourceType>;
+};
+
/**
* Signals to open a dialog with the DesktopPicker component.
*
@@ -10,7 +15,7 @@ import DesktopPicker from './components/DesktopPicker';
* a DesktopCapturerSource has been chosen.
* @returns {Object}
*/
-export function showDesktopPicker(options: { desktopSharingSources?: any; } = {}, onSourceChoose: Function) {
+export function showDesktopPicker(options: Options = {}, onSourceChoose: Function) {
const { desktopSharingSources } = options;
return openDialog(DesktopPicker, {
diff --git a/react/features/desktop-picker/components/DesktopPicker.tsx b/react/features/desktop-picker/components/DesktopPicker.tsx
index 43416f2170..d15460550a 100644
--- a/react/features/desktop-picker/components/DesktopPicker.tsx
+++ b/react/features/desktop-picker/components/DesktopPicker.tsx
@@ -5,6 +5,7 @@ import { connect } from 'react-redux';
import { IStore } from '../../app/types';
import { hideDialog } from '../../base/dialog/actions';
import { translate } from '../../base/i18n/functions';
+import { DesktopSharingSourceType } from '../../base/tracks/types';
import Dialog from '../../base/ui/components/web/Dialog';
import Tabs from '../../base/ui/components/web/Tabs';
import { THUMBNAIL_SIZE } from '../constants';
@@ -32,7 +33,7 @@ const TAB_LABELS = {
window: 'dialog.applicationWindow'
};
-const VALID_TYPES = Object.keys(TAB_LABELS);
+const VALID_TYPES = Object.keys(TAB_LABELS) as DesktopSharingSourceType[];
/**
* The type of the React {@code Component} props of {@link DesktopPicker}.
@@ -42,7 +43,7 @@ interface IProps extends WithTranslation {
/**
* An array with desktop sharing sources to be displayed.
*/
- desktopSharingSources: Array<string>;
+ desktopSharingSources: Array<DesktopSharingSourceType>;
/**
* Used to request DesktopCapturerSources.
@@ -84,7 +85,7 @@ interface IState {
/**
* The desktop source types to fetch previews for.
*/
- types: Array<string>;
+ types: Array<DesktopSharingSourceType>;
}
@@ -112,7 +113,7 @@ class DesktopPicker extends PureComponent<IProps, IState> {
* @private
* @returns {Array<string>} The filtered types.
*/
- static _getValidTypes(types: string[] = []) {
+ static _getValidTypes(types: DesktopSharingSourceType[] = []) {
return types.filter(
type => VALID_TYPES.includes(type));
}
@@ -346,10 +347,10 @@ class DesktopPicker extends PureComponent<IProps, IState> {
= types.map(
type => {
return {
- accessibilityLabel: t(TAB_LABELS[type as keyof typeof TAB_LABELS]),
+ accessibilityLabel: t(TAB_LABELS[type]),
id: `${type}`,
controlsId: `${type}-panel`,
- label: t(TAB_LABELS[type as keyof typeof TAB_LABELS])
+ label: t(TAB_LABELS[type])
};
});