fix regression breaking venmic (#531)
This commit is contained in:
parent
ab9e8579ee
commit
2733727a40
3 changed files with 29 additions and 9 deletions
25
src/renderer/patches/hideVenmicInput.tsx
Normal file
25
src/renderer/patches/hideVenmicInput.tsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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: 'setSinkId"in',
|
||||||
|
replacement: {
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
match: /return (\i)\?navigator\.mediaDevices\.enumerateDevices/,
|
||||||
|
replace: "return $1 ? $self.filteredDevices"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
async filteredDevices() {
|
||||||
|
const original = await navigator.mediaDevices.enumerateDevices();
|
||||||
|
return original.filter(x => x.label !== "vencord-screen-share");
|
||||||
|
}
|
||||||
|
});
|
|
@ -8,6 +8,7 @@
|
||||||
import "./enableNotificationsByDefault";
|
import "./enableNotificationsByDefault";
|
||||||
import "./platformClass";
|
import "./platformClass";
|
||||||
import "./hideSwitchDevice";
|
import "./hideSwitchDevice";
|
||||||
|
import "./hideVenmicInput";
|
||||||
import "./screenShareFixes";
|
import "./screenShareFixes";
|
||||||
import "./spellCheck";
|
import "./spellCheck";
|
||||||
import "./windowsTitleBar";
|
import "./windowsTitleBar";
|
||||||
|
|
|
@ -11,12 +11,11 @@ import { isLinux } from "renderer/utils";
|
||||||
const logger = new Logger("VesktopStreamFixes");
|
const logger = new Logger("VesktopStreamFixes");
|
||||||
|
|
||||||
if (isLinux) {
|
if (isLinux) {
|
||||||
const originalMedia = navigator.mediaDevices.getDisplayMedia;
|
const original = navigator.mediaDevices.getDisplayMedia;
|
||||||
const originalDevices = navigator.mediaDevices.enumerateDevices;
|
|
||||||
|
|
||||||
async function getVirtmic() {
|
async function getVirtmic() {
|
||||||
try {
|
try {
|
||||||
const devices = await originalDevices();
|
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||||
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
||||||
return audioDevice?.deviceId;
|
return audioDevice?.deviceId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -24,13 +23,8 @@ 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) {
|
navigator.mediaDevices.getDisplayMedia = async function (opts) {
|
||||||
const stream = await originalMedia.call(this, opts);
|
const stream = await original.call(this, opts);
|
||||||
const id = await getVirtmic();
|
const id = await getVirtmic();
|
||||||
|
|
||||||
const frameRate = Number(currentSettings?.fps);
|
const frameRate = Number(currentSettings?.fps);
|
||||||
|
|
Loading…
Reference in a new issue