fixed crash when cancelling screenshare

This commit is contained in:
Kaitlyn 2023-09-28 17:12:27 -04:00
parent 691997da12
commit 5001300a3b
2 changed files with 9 additions and 5 deletions

View file

@ -52,9 +52,12 @@ export function registerScreenShareHandler() {
if (isWayland) {
const video = data[0];
if (video)
await request.frame.executeJavaScript(
`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify([video])}, true)`
);
var stream = await request.frame
.executeJavaScript(
`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify([video])}, true)`
)
.catch(() => null);
if (stream === null) return callback({});
callback(video ? { video: sources[0] } : {});
return;
@ -71,6 +74,7 @@ export function registerScreenShareHandler() {
if (!choice) return callback({});
const source = sources.find(s => s.id === choice.id);
if (!source) return callback({});
const streams: Streams = {

View file

@ -71,7 +71,7 @@ addPatch({
}
});
export function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
export async function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
let didSubmit = false;
return new Promise<StreamPick>((resolve, reject) => {
const key = openModal(
@ -98,7 +98,7 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
}
}
);
});
}).catch(null);
}
function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScreen: (id: string) => void }) {