diff --git a/src/main/virtmic.ts b/src/main/virtmic.ts index ce84700..447aa4e 100644 --- a/src/main/virtmic.ts +++ b/src/main/virtmic.ts @@ -50,4 +50,4 @@ ipcMain.handle( () => obtainVenmic()?.link("application.process.id", getRendererAudioServicePid(), "exclude") ); -ipcMain.handle(IpcEvents.VIRT_MIC_KILL, () => obtainVenmic()?.unlink()); +ipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink()); diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 254e0f4..1aa6e64 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -64,7 +64,7 @@ export const VesktopNative = { list: () => invoke(IpcEvents.VIRT_MIC_LIST), start: (target: string) => invoke(IpcEvents.VIRT_MIC_START, target), startSystem: () => invoke(IpcEvents.VIRT_MIC_START_SYSTEM), - kill: () => invoke(IpcEvents.VIRT_MIC_KILL) + stop: () => invoke(IpcEvents.VIRT_MIC_STOP) }, arrpc: { onActivity(cb: (data: string) => void) { diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 72c7494..e4bed52 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -7,8 +7,18 @@ import "./screenSharePicker.css"; import { closeModal, Modals, openModal, useAwaiter } from "@vencord/types/utils"; -import { findStoreLazy } from "@vencord/types/webpack"; -import { Button, Card, Forms, Select, Switch, Text, useState } from "@vencord/types/webpack/common"; +import { findStoreLazy, onceReady } from "@vencord/types/webpack"; +import { + Button, + Card, + FluxDispatcher, + Forms, + Select, + Switch, + Text, + UserStore, + useState +} from "@vencord/types/webpack/common"; import type { Dispatch, SetStateAction } from "react"; import { addPatch } from "renderer/patches/shared"; import { isLinux, isWindows } from "renderer/utils"; @@ -71,6 +81,17 @@ addPatch({ } }); +if (isLinux) { + onceReady.then(() => { + FluxDispatcher.subscribe("VOICE_STATE_UPDATES", e => { + for (const state of e.voiceStates) { + if (state.userId === UserStore.getCurrentUser().id && state.oldChannelId && !state.channelId) + VesktopNative.virtmic.stop(); + } + }); + }); +} + export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { let didSubmit = false; return new Promise((resolve, reject) => { diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index 78cb322..bd857c4 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -45,7 +45,7 @@ export const enum IpcEvents { VIRT_MIC_LIST = "VCD_VIRT_MIC_LIST", VIRT_MIC_START = "VCD_VIRT_MIC_START", VIRT_MIC_START_SYSTEM = "VCD_VIRT_MIC_START_ALL", - VIRT_MIC_KILL = "VCD_VIRT_MIC_STOP", + VIRT_MIC_STOP = "VCD_VIRT_MIC_STOP", ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY" }