Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): implement arrpc's link event #1016

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/arrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export async function initArRPC() {
.executeJavaScript(`Vesktop.openInviteModal(${JSON.stringify(invite)})`)
.then(callback);
});
server.on("link", (data: any, deep_callback: (valid: boolean) => void) => {
Covkie marked this conversation as resolved.
Show resolved Hide resolved
mainWin.webContents.executeJavaScript(`Vesktop.openDeepLink(${JSON.stringify(data)})`).then(deep_callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know you copy pasted this from the invite but I will add proper IPC that isn't just eval to main and then you can switch ur PR to that

});
} catch (e) {
console.error("Failed to start arRPC server", e);
}
Expand Down
17 changes: 17 additions & 0 deletions src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ export async function openInviteModal(code: string) {
return true;
}

export async function openDeepLink(data: any) {
console.log(data);
if (data.type === "CHANNEL") {
// I am unaware of any other types but ensure just in case.
const { guildId, channelId, messageId } = data.params;
if (!guildId) return false; // ensure at least guildId exists

const path = [guildId, channelId, messageId].filter(Boolean).join("/");
Vencord.Webpack.Common.NavigationRouter.transitionTo(`/channels/${path}`);

return true;
} else {
console.warn("Unhandled deep link type: ", data.type);
return false;
}
}

const customSettingsSections = (
Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record<string, unknown>) => any)[] }
).customSections;
Expand Down
Loading