refactor: review suggestions

This commit is contained in:
Curve 2024-01-25 08:55:35 +01:00
parent 95acf9cdb4
commit e52d82daab
No known key found for this signature in database
GPG key ID: D4A4F11797B83017

View file

@ -4,7 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors * Copyright (c) 2023 Vendicated and Vencord contributors
*/ */
import { PatchBay } from "@vencord/venmic"; import type { PatchBay } from "@vencord/venmic";
import { app, ipcMain } from "electron"; import { app, ipcMain } from "electron";
import { join } from "path"; import { join } from "path";
import { IpcEvents } from "shared/IpcEvents"; import { IpcEvents } from "shared/IpcEvents";
@ -55,14 +55,16 @@ ipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => {
}); });
ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boolean) => { ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boolean) => {
const pid = getRendererAudioServicePid();
const data: LinkData = { const data: LinkData = {
include: targets.map(target => ({ key: "application.name", value: target })), include: targets.map(target => ({ key: "application.name", value: target })),
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }] exclude: [{ key: "application.process.id", value: pid }]
}; };
if (workaround) { if (workaround) {
data.workaround = [ data.workaround = [
{ key: "application.process.id", value: getRendererAudioServicePid() }, { key: "application.process.id", value: pid },
{ key: "media.name", value: "RecordStream" } { key: "media.name", value: "RecordStream" }
]; ];
} }
@ -71,13 +73,15 @@ ipcMain.handle(IpcEvents.VIRT_MIC_START, (_, targets: string[], workaround?: boo
}); });
ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean) => { ipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, workaround?: boolean) => {
const pid = getRendererAudioServicePid();
const data: LinkData = { const data: LinkData = {
exclude: [{ key: "application.process.id", value: getRendererAudioServicePid() }] exclude: [{ key: "application.process.id", value: pid }]
}; };
if (workaround) { if (workaround) {
data.workaround = [ data.workaround = [
{ key: "application.process.id", value: getRendererAudioServicePid() }, { key: "application.process.id", value: pid },
{ key: "media.name", value: "RecordStream" } { key: "media.name", value: "RecordStream" }
]; ];
} }