Merge pull request #6727 from SimonBrandner/task/i-hate-my-code
This commit is contained in:
commit
1a4859ede8
3 changed files with 42 additions and 15 deletions
20
src/@types/global.d.ts
vendored
20
src/@types/global.d.ts
vendored
|
@ -93,6 +93,26 @@ declare global {
|
||||||
mxSetupEncryptionStore?: SetupEncryptionStore;
|
mxSetupEncryptionStore?: SetupEncryptionStore;
|
||||||
mxRoomScrollStateStore?: RoomScrollStateStore;
|
mxRoomScrollStateStore?: RoomScrollStateStore;
|
||||||
mxOnRecaptchaLoaded?: () => void;
|
mxOnRecaptchaLoaded?: () => void;
|
||||||
|
electron?: Electron;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DesktopCapturerSource {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
thumbnailURL: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetSourcesOptions {
|
||||||
|
types: Array<string>;
|
||||||
|
thumbnailSize?: {
|
||||||
|
height: number;
|
||||||
|
width: number;
|
||||||
|
};
|
||||||
|
fetchWindowIcons?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Electron {
|
||||||
|
getDesktopCapturerSources(options: GetSourcesOptions): Promise<Array<DesktopCapturerSource>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Document {
|
interface Document {
|
||||||
|
|
|
@ -20,14 +20,21 @@ import BaseDialog from "..//dialogs/BaseDialog";
|
||||||
import DialogButtons from "./DialogButtons";
|
import DialogButtons from "./DialogButtons";
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import AccessibleButton from './AccessibleButton';
|
import AccessibleButton from './AccessibleButton';
|
||||||
import { getDesktopCapturerSources } from "matrix-js-sdk/src/webrtc/call";
|
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView';
|
import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView';
|
||||||
|
|
||||||
export interface DesktopCapturerSource {
|
export function getDesktopCapturerSources(): Promise<Array<DesktopCapturerSource>> {
|
||||||
id: string;
|
const options: GetSourcesOptions = {
|
||||||
name: string;
|
thumbnailSize: {
|
||||||
thumbnailURL;
|
height: 176,
|
||||||
|
width: 312,
|
||||||
|
},
|
||||||
|
types: [
|
||||||
|
"screen",
|
||||||
|
"window",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
return window.electron.getDesktopCapturerSources(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Tabs {
|
export enum Tabs {
|
||||||
|
@ -78,7 +85,7 @@ export interface PickerIState {
|
||||||
selectedSource: DesktopCapturerSource | null;
|
selectedSource: DesktopCapturerSource | null;
|
||||||
}
|
}
|
||||||
export interface PickerIProps {
|
export interface PickerIProps {
|
||||||
onFinished(source: DesktopCapturerSource): void;
|
onFinished(sourceId: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.elements.DesktopCapturerSourcePicker")
|
@replaceableComponent("views.elements.DesktopCapturerSourcePicker")
|
||||||
|
@ -123,7 +130,7 @@ export default class DesktopCapturerSourcePicker extends React.Component<
|
||||||
};
|
};
|
||||||
|
|
||||||
private onShare = (): void => {
|
private onShare = (): void => {
|
||||||
this.props.onFinished(this.state.selectedSource);
|
this.props.onFinished(this.state.selectedSource.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
private onTabChange = (): void => {
|
private onTabChange = (): void => {
|
||||||
|
|
|
@ -273,14 +273,14 @@ export default class CallView extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onScreenshareClick = async (): Promise<void> => {
|
private onScreenshareClick = async (): Promise<void> => {
|
||||||
const isScreensharing = await this.props.call.setScreensharingEnabled(
|
let isScreensharing;
|
||||||
!this.state.screensharing,
|
if (this.state.screensharing) {
|
||||||
async (): Promise<DesktopCapturerSource> => {
|
isScreensharing = await this.props.call.setScreensharingEnabled(false);
|
||||||
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
|
} else {
|
||||||
const [source] = await finished;
|
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
|
||||||
return source;
|
const [source] = await finished;
|
||||||
},
|
isScreensharing = await this.props.call.setScreensharingEnabled(true, source);
|
||||||
);
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
sidebarShown: true,
|
sidebarShown: true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue