Improve Venmic Usability (#504)

This commit is contained in:
Noah
2024-04-20 16:09:40 +02:00
committed by GitHub
parent 8eaa5206b9
commit 2649598361
8 changed files with 127 additions and 59 deletions

View File

@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { addPatch } from "./shared";
addPatch({
patches: [
{
find: "lastOutputSystemDevice.justChanged",
replacement: {
// eslint-disable-next-line no-useless-escape
match: /(\i)\.default\.getState\(\).neverShowModal/,
replace: "$& || $self.shouldIgnore($1)"
}
}
],
shouldIgnore(state: any) {
return Object.keys(state?.default?.lastDeviceConnected ?? {})?.[0] === "vencord-screen-share";
}
});

View File

@@ -7,6 +7,7 @@
// TODO: Possibly auto generate glob if we have more patches in the future
import "./enableNotificationsByDefault";
import "./platformClass";
import "./hideSwitchDevice";
import "./screenShareFixes";
import "./spellCheck";
import "./windowsTitleBar";

View File

@@ -11,11 +11,12 @@ import { isLinux } from "renderer/utils";
const logger = new Logger("VesktopStreamFixes");
if (isLinux) {
const original = navigator.mediaDevices.getDisplayMedia;
const originalMedia = navigator.mediaDevices.getDisplayMedia;
const originalDevices = navigator.mediaDevices.enumerateDevices;
async function getVirtmic() {
try {
const devices = await navigator.mediaDevices.enumerateDevices();
const devices = await originalDevices();
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
return audioDevice?.deviceId;
} catch (error) {
@@ -23,8 +24,13 @@ if (isLinux) {
}
}
navigator.mediaDevices.enumerateDevices = async function () {
const result = await originalDevices.call(this);
return result.filter(x => x.label !== "vencord-screen-share");
};
navigator.mediaDevices.getDisplayMedia = async function (opts) {
const stream = await original.call(this, opts);
const stream = await originalMedia.call(this, opts);
const id = await getVirtmic();
const frameRate = Number(currentSettings?.fps);