Skip to content

Commit

Permalink
Switch to the new session API for screen-sharing
Browse files Browse the repository at this point in the history
See electron/electron#30702 - this has the benefit of the js-sdk and LiveKit not having to add custom logic for Electron

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
  • Loading branch information
SimonBrandner committed Jul 14, 2023
1 parent b89b000 commit d9a4149
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/@types/global.d.ts
Expand Up @@ -32,7 +32,8 @@ type ElectronChannel =
| "setBadgeCount"
| "update-downloaded"
| "userDownloadCompleted"
| "userDownloadAction";
| "userDownloadAction"
| "openDesktopCapturerSourcePicker";

declare global {
interface Window {
Expand Down
13 changes: 11 additions & 2 deletions src/vector/platform/ElectronPlatform.tsx
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -417,13 +426,13 @@ export default class ElectronPlatform extends VectorBasePlatform {
public async destroyPickleKey(userId: string, deviceId: string): Promise<void> {
try {
await this.ipc.call("destroyPickleKey", userId, deviceId);
} catch (e) {}
} catch (e) { }
}

public async clearStorage(): Promise<void> {
try {
await super.clearStorage();
await this.ipc.call("clearStorage");
} catch (e) {}
} catch (e) { }
}
}

0 comments on commit d9a4149

Please sign in to comment.