arrpc: support OBS auto streamer mode (#822)
Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
@@ -4,23 +4,36 @@
|
||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import { findLazy, onceReady } from "@vencord/types/webpack";
|
||||
import { findLazy, findStoreLazy, onceReady } from "@vencord/types/webpack";
|
||||
import { FluxDispatcher, InviteActions } from "@vencord/types/webpack/common";
|
||||
import { IpcCommands } from "shared/IpcEvents";
|
||||
|
||||
import { onIpcCommand } from "./ipcCommands";
|
||||
import { Settings } from "./settings";
|
||||
|
||||
const StreamerModeStore = findStoreLazy("StreamerModeStore");
|
||||
|
||||
const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"] as any as {
|
||||
handleEvent(e: MessageEvent): void;
|
||||
};
|
||||
|
||||
onIpcCommand(IpcCommands.RPC_ACTIVITY, async data => {
|
||||
onIpcCommand(IpcCommands.RPC_ACTIVITY, async jsonData => {
|
||||
if (!Settings.store.arRPC) return;
|
||||
|
||||
await onceReady;
|
||||
|
||||
arRPC.handleEvent(new MessageEvent("message", { data }));
|
||||
const data = JSON.parse(jsonData);
|
||||
|
||||
if (data.socketId === "STREAMERMODE" && StreamerModeStore.autoToggle) {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "STREAMER_MODE_UPDATE",
|
||||
key: "enabled",
|
||||
value: data.activity?.application_id === "STREAMERMODE"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
arRPC.handleEvent(new MessageEvent("message", { data: jsonData }));
|
||||
});
|
||||
|
||||
onIpcCommand(IpcCommands.RPC_INVITE, async code => {
|
||||
|
||||
@@ -12,4 +12,5 @@ import "./hideVenmicInput";
|
||||
import "./screenShareFixes";
|
||||
import "./spellCheck";
|
||||
import "./windowsTitleBar";
|
||||
import "./streamerMode";
|
||||
import "./nativeFocus";
|
||||
|
||||
21
src/renderer/patches/streamerMode.ts
Normal file
21
src/renderer/patches/streamerMode.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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: ".STREAMER_MODE_ENABLE,",
|
||||
replacement: {
|
||||
// remove if (platformEmbedded) check from streamer mode toggle
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
match: /if\(\i\.\i\)(?=return.{0,200}?"autoToggle")/g,
|
||||
replace: ""
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user