From d9a41495707427dbb0972e18a8403a0dcb28024a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 14 Jul 2023 12:09:10 +0200 Subject: [PATCH] Switch to the new `session` API for screen-sharing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/electron/electron/pull/30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron Signed-off-by: Šimon Brandner --- src/@types/global.d.ts | 3 ++- src/vector/platform/ElectronPlatform.tsx | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 5047aeeed5e..0145673ec98 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -32,7 +32,8 @@ type ElectronChannel = | "setBadgeCount" | "update-downloaded" | "userDownloadCompleted" - | "userDownloadAction"; + | "userDownloadAction" + | "openDesktopCapturerSourcePicker"; declare global { interface Window { diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index b18b1abe4ec..605fab9cbab 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -43,6 +43,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { BreadcrumbsStore } from "matrix-react-sdk/src/stores/BreadcrumbsStore"; import { UPDATE_EVENT } from "matrix-react-sdk/src/stores/AsyncStore"; import { avatarUrlForRoom, getInitialLetter } from "matrix-react-sdk/src/Avatar"; +import DesktopCapturerSourcePicker from "matrix-react-sdk/src/components/views/elements/DesktopCapturerSourcePicker"; import VectorBasePlatform from "./VectorBasePlatform"; import { SeshatIndexManager } from "./SeshatIndexManager"; @@ -163,6 +164,14 @@ export default class ElectronPlatform extends VectorBasePlatform { }); }); + window.electron.on("openDesktopCapturerSourcePicker", async () => { + const { finished } = Modal.createDialog(DesktopCapturerSourcePicker); + const [source] = await finished; + if (!source) return; + + this.ipc.call("callDisplayMediaCallback", source) + }) + this.ipc.call("startSSOFlow", this.ssoID); BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate); @@ -417,13 +426,13 @@ export default class ElectronPlatform extends VectorBasePlatform { public async destroyPickleKey(userId: string, deviceId: string): Promise { try { await this.ipc.call("destroyPickleKey", userId, deviceId); - } catch (e) {} + } catch (e) { } } public async clearStorage(): Promise { try { await super.clearStorage(); await this.ipc.call("clearStorage"); - } catch (e) {} + } catch (e) { } } }