Switch to IPC channel for getDesktopCapturerSources (#7782)

This commit is contained in:
Šimon Brandner 2022-02-11 11:41:15 +01:00 committed by GitHub
parent c3bb8cf3ef
commit 73899bb2e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View file

@ -109,7 +109,7 @@ declare global {
mxActiveWidgetStore?: ActiveWidgetStore; mxActiveWidgetStore?: ActiveWidgetStore;
mxSkinner?: Skinner; mxSkinner?: Skinner;
mxOnRecaptchaLoaded?: () => void; mxOnRecaptchaLoaded?: () => void;
electron?: Electron; electron?: unknown;
mxSendSentryReport: (userText: string, issueUrl: string, error: Error) => Promise<void>; mxSendSentryReport: (userText: string, issueUrl: string, error: Error) => Promise<void>;
mxLoginWithAccessToken: (hsUrl: string, accessToken: string) => Promise<void>; mxLoginWithAccessToken: (hsUrl: string, accessToken: string) => Promise<void>;
mxAutoRageshakeStore?: AutoRageshakeStore; mxAutoRageshakeStore?: AutoRageshakeStore;
@ -130,10 +130,6 @@ declare global {
fetchWindowIcons?: boolean; fetchWindowIcons?: boolean;
} }
interface Electron {
getDesktopCapturerSources(options: GetSourcesOptions): Promise<Array<DesktopCapturerSource>>;
}
interface Document { interface Document {
// Safari & IE11 only have this prefixed: we used prefixed versions // Safari & IE11 only have this prefixed: we used prefixed versions
// previously so let's continue to support them for now // previously so let's continue to support them for now

View file

@ -301,6 +301,14 @@ export default abstract class BasePlatform {
return null; return null;
} }
async getDesktopCapturerSources(options: GetSourcesOptions): Promise<Array<DesktopCapturerSource>> {
return [];
}
supportsDesktopCapturer(): boolean {
return false;
}
getAvailableSpellCheckLanguages(): Promise<string[]> | null { getAvailableSpellCheckLanguages(): Promise<string[]> | null {
return null; return null;
} }

View file

@ -23,6 +23,7 @@ import DialogButtons from "./DialogButtons";
import AccessibleButton from './AccessibleButton'; import AccessibleButton from './AccessibleButton';
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView'; import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView';
import PlatformPeg from "../../../PlatformPeg";
export function getDesktopCapturerSources(): Promise<Array<DesktopCapturerSource>> { export function getDesktopCapturerSources(): Promise<Array<DesktopCapturerSource>> {
const options: GetSourcesOptions = { const options: GetSourcesOptions = {
@ -35,7 +36,7 @@ export function getDesktopCapturerSources(): Promise<Array<DesktopCapturerSource
"window", "window",
], ],
}; };
return window.electron.getDesktopCapturerSources(options); return PlatformPeg.get().getDesktopCapturerSources(options);
} }
export enum Tabs { export enum Tabs {

View file

@ -37,6 +37,7 @@ import Modal from '../../../Modal';
import CallViewSidebar from './CallViewSidebar'; import CallViewSidebar from './CallViewSidebar';
import CallViewHeader from './CallView/CallViewHeader'; import CallViewHeader from './CallView/CallViewHeader';
import CallViewButtons from "./CallView/CallViewButtons"; import CallViewButtons from "./CallView/CallViewButtons";
import PlatformPeg from "../../../PlatformPeg";
interface IProps { interface IProps {
// The call for us to display // The call for us to display
@ -270,7 +271,7 @@ export default class CallView extends React.Component<IProps, IState> {
if (this.state.screensharing) { if (this.state.screensharing) {
isScreensharing = await this.props.call.setScreensharingEnabled(false); isScreensharing = await this.props.call.setScreensharingEnabled(false);
} else { } else {
if (window.electron?.getDesktopCapturerSources) { if (PlatformPeg.get().supportsDesktopCapturer()) {
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker); const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
const [source] = await finished; const [source] = await finished;
if (!source) return; if (!source) return;