From 73899bb2e30ebb8bb79021ecf2bf145ae7b3be62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 11 Feb 2022 11:41:15 +0100 Subject: [PATCH] Switch to IPC channel for `getDesktopCapturerSources` (#7782) --- src/@types/global.d.ts | 6 +----- src/BasePlatform.ts | 8 ++++++++ .../views/elements/DesktopCapturerSourcePicker.tsx | 3 ++- src/components/views/voip/CallView.tsx | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 9c2e7677ed..ddf3f40c62 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -109,7 +109,7 @@ declare global { mxActiveWidgetStore?: ActiveWidgetStore; mxSkinner?: Skinner; mxOnRecaptchaLoaded?: () => void; - electron?: Electron; + electron?: unknown; mxSendSentryReport: (userText: string, issueUrl: string, error: Error) => Promise; mxLoginWithAccessToken: (hsUrl: string, accessToken: string) => Promise; mxAutoRageshakeStore?: AutoRageshakeStore; @@ -130,10 +130,6 @@ declare global { fetchWindowIcons?: boolean; } - interface Electron { - getDesktopCapturerSources(options: GetSourcesOptions): Promise>; - } - interface Document { // Safari & IE11 only have this prefixed: we used prefixed versions // previously so let's continue to support them for now diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 4e02325bed..048ed30c06 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -301,6 +301,14 @@ export default abstract class BasePlatform { return null; } + async getDesktopCapturerSources(options: GetSourcesOptions): Promise> { + return []; + } + + supportsDesktopCapturer(): boolean { + return false; + } + getAvailableSpellCheckLanguages(): Promise | null { return null; } diff --git a/src/components/views/elements/DesktopCapturerSourcePicker.tsx b/src/components/views/elements/DesktopCapturerSourcePicker.tsx index 6c5dbca659..57bf24b777 100644 --- a/src/components/views/elements/DesktopCapturerSourcePicker.tsx +++ b/src/components/views/elements/DesktopCapturerSourcePicker.tsx @@ -23,6 +23,7 @@ import DialogButtons from "./DialogButtons"; import AccessibleButton from './AccessibleButton'; import { replaceableComponent } from "../../../utils/replaceableComponent"; import TabbedView, { Tab, TabLocation } from '../../structures/TabbedView'; +import PlatformPeg from "../../../PlatformPeg"; export function getDesktopCapturerSources(): Promise> { const options: GetSourcesOptions = { @@ -35,7 +36,7 @@ export function getDesktopCapturerSources(): Promise { if (this.state.screensharing) { isScreensharing = await this.props.call.setScreensharingEnabled(false); } else { - if (window.electron?.getDesktopCapturerSources) { + if (PlatformPeg.get().supportsDesktopCapturer()) { const { finished } = Modal.createDialog(DesktopCapturerSourcePicker); const [source] = await finished; if (!source) return;