diff --git a/src/equicordplugins/instantScreenshare/index.tsx b/src/equicordplugins/instantScreenshare/index.tsx index 1a29d719f..1d0160048 100644 --- a/src/equicordplugins/instantScreenshare/index.tsx +++ b/src/equicordplugins/instantScreenshare/index.tsx @@ -15,8 +15,9 @@ import { ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, Selec import { getCurrentMedia, settings } from "./utils"; -let hasStreamed; +let hasStreamed, isStreaming, streamKey; const startStream = findByCodeLazy('type:"STREAM_START"'); +const stopStream = findByCodeLazy('type:"STREAM_STOP"'); const StreamPreviewSettings = getUserSettingLazy("voiceAndVideo", "disableStreamPreviews")!; const ApplicationStreamingSettingsStore = findStoreLazy("ApplicationStreamingSettingsStore"); @@ -44,14 +45,18 @@ async function autoStartStream(instant = true) { let sourceId = streamMedia.id; if (streamMedia.type === "video_device") sourceId = `camera:${streamMedia.id}`; - startStream(channel.guild_id ?? null, selected, { - "pid": null, - "sourceId": sourceId, - "sourceName": streamMedia.name, - "audioSourceId": streamMedia.name, - "sound": soundshareEnabled, - "previewDisabled": preview - }); + if (isStreaming && streamKey.endsWith(UserStore.getCurrentUser().id)) { + stopStream(streamKey); + } else { + startStream(channel.guild_id ?? null, selected, { + "pid": null, + "sourceId": sourceId, + "sourceName": streamMedia.name, + "audioSourceId": streamMedia.name, + "sound": soundshareEnabled, + "previewDisabled": preview + }); + } } export default definePlugin({ @@ -122,6 +127,14 @@ export default definePlugin({ break; } + }, + STREAM_CREATE: d => { + streamKey = d; + isStreaming = true; + }, + STREAM_DELETE: d => { + streamKey = d; + isStreaming = false; } }, diff --git a/src/plugins/betterSettings/index.tsx b/src/plugins/betterSettings/index.tsx index 2ff627903..7360c32a3 100644 --- a/src/plugins/betterSettings/index.tsx +++ b/src/plugins/betterSettings/index.tsx @@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findCssClassesLazy } from "@webpack"; import { ComponentDispatch, FocusLock, Menu, useEffect, useRef } from "@webpack/common"; -import type { HTMLAttributes } from "react"; +import type { HTMLAttributes, ReactNode } from "react"; import fullHeightStyle from "./fullHeightContext.css?managed"; @@ -154,8 +154,8 @@ export default definePlugin({ predicate: () => settings.store.organizeMenu, replacement: [ { - match: /(\i)=(.{0,20}openUserSettings\)\(\i\)\));/, - replace: "$1=$self.transformSettingsElements($2);", + match: /children:\[(\i),(?<=\1=.{0,30}\.openUserSettings.+?)/, + replace: "children:[$self.transformSettingsEntries($1),", }, ] }, @@ -179,8 +179,8 @@ export default definePlugin({ return ; }, - transformSettingsElements(list) { - const items: any[] = []; + transformSettingsEntries(list) { + const items: ReactNode[] = []; for (const item of list) { const { key, props } = item; @@ -199,7 +199,7 @@ export default definePlugin({ } else if (key.endsWith("_section") && props.label) { items.push( - {this.transformSettingsElements(props.children)} + {this.transformSettingsEntries(props.children)} ); } else {