From 0fb79b763d797d70d2eb6d847b0bf711c9927337 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 19 Mar 2023 04:53:00 -0300 Subject: Improvements, changes and fixes (#611) --- src/api/ContextMenu.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/api/ContextMenu.ts') 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, args?: Array) => void; +export type NavContextMenuPatchCallback = (children: Array, ...args: Array) => 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, args?: Array) => void; +export type GlobalContextMenuPatchCallback = (navId: string, children: Array, ...args: Array) => 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); } -- cgit