mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-22 21:35:08 +00:00
feat(rpc): implement arrpc's link
event (#1016)
Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
parent
c9be618164
commit
56442ae1e9
6 changed files with 45 additions and 7 deletions
|
@ -26,6 +26,9 @@ export async function initArRPC() {
|
||||||
|
|
||||||
await sendRendererCommand(IpcCommands.RPC_INVITE, invite).then(callback);
|
await sendRendererCommand(IpcCommands.RPC_INVITE, invite).then(callback);
|
||||||
});
|
});
|
||||||
|
server.on("link", async (data: any, deepCallback: (valid: boolean) => void) => {
|
||||||
|
await sendRendererCommand(IpcCommands.RPC_DEEP_LINK, data).then(deepCallback);
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to start arRPC server", e);
|
console.error("Failed to start arRPC server", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { onceReady } from "@vencord/types/webpack";
|
import { findLazy, onceReady } from "@vencord/types/webpack";
|
||||||
import { FluxDispatcher, InviteActions } from "@vencord/types/webpack/common";
|
import { FluxDispatcher, InviteActions } from "@vencord/types/webpack/common";
|
||||||
import { IpcCommands } from "shared/IpcEvents";
|
import { IpcCommands } from "shared/IpcEvents";
|
||||||
|
|
||||||
|
@ -38,3 +38,15 @@ onIpcCommand(IpcCommands.RPC_INVITE, async code => {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { DEEP_LINK } = findLazy(m => m.DEEP_LINK?.handler);
|
||||||
|
|
||||||
|
onIpcCommand(IpcCommands.RPC_DEEP_LINK, async data => {
|
||||||
|
try {
|
||||||
|
DEEP_LINK.handler({ args: data });
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[RPC]", "Failed to open deep link:", err, data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -4,25 +4,23 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "./fixes";
|
|
||||||
import "./appBadge";
|
|
||||||
import "./patches";
|
|
||||||
import "./themedSplash";
|
import "./themedSplash";
|
||||||
import "./ipcCommands";
|
import "./ipcCommands";
|
||||||
|
import "./appBadge";
|
||||||
|
import "./patches";
|
||||||
|
import "./fixes";
|
||||||
import "./arrpc";
|
import "./arrpc";
|
||||||
|
|
||||||
console.log("read if cute :3");
|
console.log("read if cute :3");
|
||||||
|
|
||||||
export * as Components from "./components";
|
export * as Components from "./components";
|
||||||
import { findByPropsLazy, onceReady } from "@vencord/types/webpack";
|
import { onceReady } from "@vencord/types/webpack";
|
||||||
import { Alerts } from "@vencord/types/webpack/common";
|
import { Alerts } from "@vencord/types/webpack/common";
|
||||||
|
|
||||||
import SettingsUi from "./components/settings/Settings";
|
import SettingsUi from "./components/settings/Settings";
|
||||||
import { Settings } from "./settings";
|
import { Settings } from "./settings";
|
||||||
export { Settings };
|
export { Settings };
|
||||||
|
|
||||||
const InviteActions = findByPropsLazy("resolveInvite");
|
|
||||||
|
|
||||||
const customSettingsSections = (
|
const customSettingsSections = (
|
||||||
Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record<string, unknown>) => any)[] }
|
Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record<string, unknown>) => any)[] }
|
||||||
).customSections;
|
).customSections;
|
||||||
|
|
|
@ -12,3 +12,4 @@ import "./hideVenmicInput";
|
||||||
import "./screenShareFixes";
|
import "./screenShareFixes";
|
||||||
import "./spellCheck";
|
import "./spellCheck";
|
||||||
import "./windowsTitleBar";
|
import "./windowsTitleBar";
|
||||||
|
import "./nativeFocus";
|
||||||
|
|
23
src/renderer/patches/nativeFocus.tsx
Normal file
23
src/renderer/patches/nativeFocus.tsx
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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: ".DEEP_LINK]:{",
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
// TODO: Fix eslint rule
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
match: /(?<=\.DEEP_LINK.{0,200}?)\i\.\i\.focus\(\)/,
|
||||||
|
replace: "VesktopNative.win.focus()"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
|
@ -61,6 +61,7 @@ export const enum IpcEvents {
|
||||||
export const enum IpcCommands {
|
export const enum IpcCommands {
|
||||||
RPC_ACTIVITY = "rpc:activity",
|
RPC_ACTIVITY = "rpc:activity",
|
||||||
RPC_INVITE = "rpc:invite",
|
RPC_INVITE = "rpc:invite",
|
||||||
|
RPC_DEEP_LINK = "rpc:link",
|
||||||
NAVIGATE_SETTINGS = "navigate:settings",
|
NAVIGATE_SETTINGS = "navigate:settings",
|
||||||
GET_LANGUAGES = "navigator.languages"
|
GET_LANGUAGES = "navigator.languages"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue