diff options
author | Nuckyz <61953774+Nuckyz@users.noreply.github.com> | 2023-03-19 04:53:00 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-19 04:53:00 -0300 |
commit | 0fb79b763d797d70d2eb6d847b0bf711c9927337 (patch) | |
tree | b95674e930baa1a9b3651185e990b46acd82f871 /src/api/ContextMenu.ts | |
parent | 5873bde6a62857f92f3fb3d756914cc1efd0ec25 (diff) | |
download | Vencord-0fb79b763d797d70d2eb6d847b0bf711c9927337.tar.gz Vencord-0fb79b763d797d70d2eb6d847b0bf711c9927337.tar.bz2 Vencord-0fb79b763d797d70d2eb6d847b0bf711c9927337.zip |
Improvements, changes and fixes (#611)
Diffstat (limited to 'src/api/ContextMenu.ts')
-rw-r--r-- | src/api/ContextMenu.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/api/ContextMenu.ts b/src/api/ContextMenu.ts index 9a8d7b6..3f73a41 100644 --- a/src/api/ContextMenu.ts +++ b/src/api/ContextMenu.ts @@ -23,13 +23,13 @@ import type { ReactElement } from "react"; * @param children The rendered context menu elements * @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example */ -export type NavContextMenuPatchCallback = (children: Array<React.ReactElement>, args?: Array<any>) => void; +export type NavContextMenuPatchCallback = (children: Array<React.ReactElement>, ...args: Array<any>) => void; /** * @param The navId of the context menu being patched * @param children The rendered context menu elements * @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example */ -export type GlobalContextMenuPatchCallback = (navId: string, children: Array<React.ReactElement>, args?: Array<any>) => void; +export type GlobalContextMenuPatchCallback = (navId: string, children: Array<React.ReactElement>, ...args: Array<any>) => void; const ContextMenuLogger = new Logger("ContextMenu"); @@ -119,12 +119,13 @@ interface ContextMenuProps { } export function _patchContextMenu(props: ContextMenuProps) { + props.contextMenuApiArguments ??= []; const contextMenuPatches = navPatches.get(props.navId); if (contextMenuPatches) { for (const patch of contextMenuPatches) { try { - patch(props.children, props.contextMenuApiArguments); + patch(props.children, ...props.contextMenuApiArguments); } catch (err) { ContextMenuLogger.error(`Patch for ${props.navId} errored,`, err); } @@ -133,7 +134,7 @@ export function _patchContextMenu(props: ContextMenuProps) { for (const patch of globalPatches) { try { - patch(props.navId, props.children, props.contextMenuApiArguments); + patch(props.navId, props.children, ...props.contextMenuApiArguments); } catch (err) { ContextMenuLogger.error("Global patch errored,", err); } |