From be3f51bff758b3cd2dab168e99811e2b3159ef1c Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 22 Jul 2023 03:39:36 +0530 Subject: [PATCH 01/34] fml --- src/renderer/coremods/contextMenu/index.tsx | 112 +++++++++++------- .../coremods/contextMenu/plaintextPatches.ts | 10 -- 2 files changed, 66 insertions(+), 56 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index ab70730d5..b8625c1ad 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -1,3 +1,6 @@ +import { Injector } from "src/renderer/modules/injector"; +import { Logger } from "src/renderer/modules/logger"; +import { filters, waitForModule } from "src/renderer/modules/webpack"; import { React } from "@common"; import type { ContextMenuProps } from "@components/ContextMenu"; import type { @@ -6,9 +9,9 @@ import type { GetContextItem, RawContextItem, } from "../../../types/coremods/contextMenu"; -import { Logger } from "../../modules/logger"; -import { getByProps } from "../../modules/webpack"; +import { AnyFunction } from "src/types"; +let injector: Injector; const logger = Logger.api("ContextMenu"); export const menuItems = {} as Record< @@ -31,6 +34,7 @@ function makeItem(raw: RawContextItem | ContextItem | undefined | void): Context return raw as ContextItem | undefined; } if (React.isValidElement(raw)) { + logger.log("huh"); // We can't construct something that's already made return raw as ContextItem | undefined; } @@ -88,53 +92,69 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { * @internal * @hidden */ -export function _insertMenuItems(menu: ContextMenuData): void { - const { navId } = menu; - // No items to insert - if (!menuItems[navId]) return; - - // Already inserted items - // If this isn't here, another group of items is added every update - if (menu.plugged) return; - - // We delay getting the items until now, as importing at the start of the file causes Discord to hang - // Using `await import(...)` is undesirable because the new items will only appear once the menu is interacted with - const { MenuGroup } = getByProps>([ +async function injectMenu(): Promise { + const RepluggedComponents = await waitForModule(filters.byProps("Menu", "MenuGroup", "MenuItem")); + injector.instead( + RepluggedComponents as Record, "Menu", - "MenuItem", - "MenuGroup", - ])!; - - if (!MenuGroup) return; - - // The data as passed as Arguments from the calling function, so we just grab what we want from it - const data = menu.data[0]; - - const repluggedGroup = ; - repluggedGroup.props.id = "replugged"; - repluggedGroup.props.children = []; - - // Add in the new menu items right above the DevMode Copy ID - // If the user doesn't have DevMode enabled, the new items will be at the bottom - menu.children.splice(-1, 0, repluggedGroup); - - menuItems[navId].forEach((item) => { - try { - const res = makeItem(item.getItem(data, menu)) as ContextItem & { props: { id?: string } }; - - if (res?.props) { - // add in unique ids - res.props.id = `${res.props.id || "repluggedItem"}-${Math.random() - .toString(36) - .substring(2)}`; + ([menu]: [ContextMenuData], res) => { + const ContextMenu = res as React.FunctionComponent; + const { navId } = menu; + const { MenuGroup } = RepluggedComponents as Record; + + // No items to insert + // Or MenuGroup Component is not available + if (!menuItems[navId] || !MenuGroup) { + return ; } - menu.children.at(item.sectionId)?.props?.children?.splice(item.indexInSection, 0, res); - } catch (err) { - logger.error("Error while running GetContextItem function", err, item.getItem); - } - }); + // The data as passed as Arguments from the calling function, so we just grab what we want from it + const data = menu.data[0]; + + const repluggedGroup = ; + repluggedGroup.props.id = "replugged"; + repluggedGroup.props.children = []; + + // Add in the new menu items right above the DevMode Copy ID + // If the user doesn't have DevMode enabled, the new items will be at the bottom + menu.children.splice(-1, 0, repluggedGroup); + menuItems[navId].forEach((item) => { + try { + const itemRet = makeItem(item.getItem(data, menu)) as ContextItem & { + props: { id?: string }; + }; + + if (itemRet?.props) { + // add in unique ids + itemRet.props.id = `${itemRet.props.id || "repluggedItem"}-${Math.random() + .toString(36) + .substring(2)}`; + } + + if (!menu.children.at(item.sectionId)?.props?.plugged) { + // menu props can stay same while having different children + // so we check children props if its plugged or not + menu.children + .at(item.sectionId) + ?.props.children?.splice(item.indexInSection, 0, itemRet); + if (menu.children.at(item.sectionId)?.props) + menu.children.at(item.sectionId)!.props.plugged = true; + } + } catch (err) { + logger.error("Error while running GetContextItem function", err, item.getItem); + } + }); + + return ; + }, + ); +} +export function start(): void { + injector = new Injector(); + void injectMenu(); +} - menu.plugged = true; +export function stop(): void { + injector.uninjectAll(); } diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index a18e8c84d..9a85363fd 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -1,16 +1,6 @@ import type { PlaintextPatch } from "src/types"; export default [ - { - find: 'Error("Menu', - replacements: [ - { - match: /var \w,\w=(.)\.navId/, - replace: (vars, menu) => - `replugged.coremods.coremods.contextMenu._insertMenuItems(${menu});${vars}`, - }, - ], - }, { find: "navId:", replacements: [ From 6c2ccb723923afc34da14b1d8927b2d6e51a15e9 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 22 Jul 2023 03:44:41 +0530 Subject: [PATCH 02/34] removed testing log --- src/renderer/coremods/contextMenu/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index b8625c1ad..783084ea4 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -34,7 +34,6 @@ function makeItem(raw: RawContextItem | ContextItem | undefined | void): Context return raw as ContextItem | undefined; } if (React.isValidElement(raw)) { - logger.log("huh"); // We can't construct something that's already made return raw as ContextItem | undefined; } From 338d02441204f78f67df27880757c55569894e76 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 23 Jul 2023 06:29:01 +0530 Subject: [PATCH 03/34] back to plain text patch --- src/renderer/coremods/contextMenu/index.tsx | 131 +++++++++--------- .../coremods/contextMenu/plaintextPatches.ts | 13 ++ 2 files changed, 78 insertions(+), 66 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 783084ea4..14155e533 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -1,6 +1,3 @@ -import { Injector } from "src/renderer/modules/injector"; -import { Logger } from "src/renderer/modules/logger"; -import { filters, waitForModule } from "src/renderer/modules/webpack"; import { React } from "@common"; import type { ContextMenuProps } from "@components/ContextMenu"; import type { @@ -9,9 +6,9 @@ import type { GetContextItem, RawContextItem, } from "../../../types/coremods/contextMenu"; -import { AnyFunction } from "src/types"; +import { Logger } from "../../modules/logger"; +import { getByProps } from "../../modules/webpack"; -let injector: Injector; const logger = Logger.api("ContextMenu"); export const menuItems = {} as Record< @@ -92,68 +89,70 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { * @hidden */ -async function injectMenu(): Promise { - const RepluggedComponents = await waitForModule(filters.byProps("Menu", "MenuGroup", "MenuItem")); - injector.instead( - RepluggedComponents as Record, - "Menu", - ([menu]: [ContextMenuData], res) => { - const ContextMenu = res as React.FunctionComponent; - const { navId } = menu; - const { MenuGroup } = RepluggedComponents as Record; - - // No items to insert - // Or MenuGroup Component is not available - if (!menuItems[navId] || !MenuGroup) { - return ; +export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { + const { navId } = menu; + const { MenuGroup, Menu: ContextMenu } = getByProps< + Record & { Menu: React.FunctionComponent } + >(["Menu", "MenuItem", "MenuGroup"])!; + //return nothing as we werent able to get ContextMenu component, gets handled in plain text patch + if (!ContextMenu) return null; + + // No items to insert + // Or MenuGroup Component is not available + if (!menuItems[navId] || !MenuGroup) return ; + + // The data as passed as Arguments from the calling function, so we just grab what we want from it + const data = menu.data[0]; + + //Add group only if it doesnt exist + if (!menu.children.some((child) => child.props.id === "replugged")) { + const repluggedGroup = ; + repluggedGroup.props.id = "replugged"; + repluggedGroup.props.children = []; + + // Add in the new menu items right above the DevMode Copy ID + // If the user doesn't have DevMode enabled, the new items will be at the bottom + menu.children.splice(-1, 0, repluggedGroup); + } + + //get sections from where to clean items + const usedSectionIds = menuItems[navId] + .map((item) => item.sectionId) + .filter((item, index, array) => array.indexOf(item) === index); + + //cleaning old items before adding new ones + usedSectionIds.forEach((sectionId) => { + try { + if (menu.children.at(sectionId)?.props?.children) { + menu.children.at(sectionId)!.props.children = menu.children + .at(sectionId) + ?.props.children.filter((child: React.ReactElement) => child.props.plugged); + } + } catch (err) { + logger.error("Error while removing old menu items", err, menu.children.at(sectionId)); + } + }); + + //adding new items + menuItems[navId].forEach((item) => { + try { + const itemRet = makeItem(item.getItem(data, menu)) as ContextItem & { + props: { replug?: boolean }; + }; + + // removed the code to add unique id everytime because it made experience bad while hovering over item and it getting updated + // should be fine because we actively keep removing old items ig + + if (itemRet?.props) { + // add in prop for cleanup + itemRet.props.replug = true; } - // The data as passed as Arguments from the calling function, so we just grab what we want from it - const data = menu.data[0]; - - const repluggedGroup = ; - repluggedGroup.props.id = "replugged"; - repluggedGroup.props.children = []; - - // Add in the new menu items right above the DevMode Copy ID - // If the user doesn't have DevMode enabled, the new items will be at the bottom - menu.children.splice(-1, 0, repluggedGroup); - menuItems[navId].forEach((item) => { - try { - const itemRet = makeItem(item.getItem(data, menu)) as ContextItem & { - props: { id?: string }; - }; - - if (itemRet?.props) { - // add in unique ids - itemRet.props.id = `${itemRet.props.id || "repluggedItem"}-${Math.random() - .toString(36) - .substring(2)}`; - } - - if (!menu.children.at(item.sectionId)?.props?.plugged) { - // menu props can stay same while having different children - // so we check children props if its plugged or not - menu.children - .at(item.sectionId) - ?.props.children?.splice(item.indexInSection, 0, itemRet); - if (menu.children.at(item.sectionId)?.props) - menu.children.at(item.sectionId)!.props.plugged = true; - } - } catch (err) { - logger.error("Error while running GetContextItem function", err, item.getItem); - } - }); - - return ; - }, - ); -} -export function start(): void { - injector = new Injector(); - void injectMenu(); -} + menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); + } catch (err) { + logger.error("Error while running GetContextItem function", err, item.getItem); + } + }); -export function stop(): void { - injector.uninjectAll(); + return ; } diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index 9a85363fd..f39674add 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -1,6 +1,19 @@ import type { PlaintextPatch } from "src/types"; export default [ + { + find: 'Error("Menu', + replacements: [ + { + match: /var \w,\w=(.)\.navId/, + replace: (vars, menu) => + `if (!${menu}.plugged){` + + `const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});` + + `if (patchedMenu!==null){return patchedMenu}` + + `};${vars}`, + }, + ], + }, { find: "navId:", replacements: [ From f9e1e03a4cc785bb0a5801078905aab08e38c028 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 23 Jul 2023 06:31:31 +0530 Subject: [PATCH 04/34] cspell will explod --- src/renderer/coremods/contextMenu/index.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 14155e533..73c5ecea3 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -84,17 +84,13 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { plugged?: boolean; }; -/** - * @internal - * @hidden - */ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { const { navId } = menu; const { MenuGroup, Menu: ContextMenu } = getByProps< Record & { Menu: React.FunctionComponent } >(["Menu", "MenuItem", "MenuGroup"])!; - //return nothing as we werent able to get ContextMenu component, gets handled in plain text patch + //return nothing as we weren't able to get ContextMenu component, gets handled in plain text patch if (!ContextMenu) return null; // No items to insert @@ -104,7 +100,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // The data as passed as Arguments from the calling function, so we just grab what we want from it const data = menu.data[0]; - //Add group only if it doesnt exist + //Add group only if it doesn't exist if (!menu.children.some((child) => child.props.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; @@ -140,7 +136,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n props: { replug?: boolean }; }; - // removed the code to add unique id everytime because it made experience bad while hovering over item and it getting updated + // removed the code to add unique id every time because it made experience bad while hovering over item and it getting updated // should be fine because we actively keep removing old items ig if (itemRet?.props) { From fc4dafa00ab0ddc8a4c8fc1c89c82dd7eb6dc484 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 23 Jul 2023 06:33:22 +0530 Subject: [PATCH 05/34] why do i have to format twice? --- src/renderer/coremods/contextMenu/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 73c5ecea3..1996783cb 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -84,7 +84,6 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { plugged?: boolean; }; - export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { const { navId } = menu; const { MenuGroup, Menu: ContextMenu } = getByProps< From 1b80faf33b0bf033ccf780acae27335a1fedcfa6 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 23 Jul 2023 06:49:33 +0530 Subject: [PATCH 06/34] ;-; --- src/renderer/coremods/contextMenu/plaintextPatches.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index f39674add..2ec99e9fa 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -10,7 +10,7 @@ export default [ `if (!${menu}.plugged){` + `const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});` + `if (patchedMenu!==null){return patchedMenu}` + - `};${vars}`, + `}${vars}`, }, ], }, From 23dbb25db8a6f1b6d4c955775f9a1f708f20608b Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 23 Jul 2023 07:45:01 +0530 Subject: [PATCH 07/34] fix some crashes sometimes --- src/renderer/coremods/contextMenu/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 1996783cb..2fa619a13 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -100,7 +100,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n const data = menu.data[0]; //Add group only if it doesn't exist - if (!menu.children.some((child) => child.props.id === "replugged")) { + if (!menu.children.some((child) => child?.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; From 5f86eefda22c5f7ca9198af173e10beabd0339b3 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Tue, 25 Jul 2023 05:06:54 +0530 Subject: [PATCH 08/34] handle non array --- src/renderer/coremods/contextMenu/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 2fa619a13..d2363d8fe 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -119,9 +119,13 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n usedSectionIds.forEach((sectionId) => { try { if (menu.children.at(sectionId)?.props?.children) { - menu.children.at(sectionId)!.props.children = menu.children - .at(sectionId) - ?.props.children.filter((child: React.ReactElement) => child.props.plugged); + menu.children.at(sectionId)!.props.children = Array.isArray( + menu.children.at(sectionId)?.props.children, + ) + ? menu.children + .at(sectionId) + ?.props.children.filter((child: React.ReactElement) => child.props.plugged) + : [menu.children.at(sectionId)?.props.children]; } } catch (err) { logger.error("Error while removing old menu items", err, menu.children.at(sectionId)); From 6c625bcde4dd5d03c78d22f4b6b21c4c3c6309bd Mon Sep 17 00:00:00 2001 From: LoneWeeb <73281112+Tharki-God@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:28:04 +0530 Subject: [PATCH 09/34] dumb me forgot this. --- src/renderer/coremods/contextMenu/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index d2363d8fe..e8eb5687d 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -124,7 +124,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n ) ? menu.children .at(sectionId) - ?.props.children.filter((child: React.ReactElement) => child.props.plugged) + ?.props.children.filter((child: React.ReactElement) => !child.props.replug) : [menu.children.at(sectionId)?.props.children]; } } catch (err) { From 06b0d06f9105ca92545b01578e9fc6c2fe215f7c Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 26 Jul 2023 05:44:16 +0530 Subject: [PATCH 10/34] done --- src/renderer/coremods/contextMenu/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index e8eb5687d..2856414dd 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -84,6 +84,10 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { plugged?: boolean; }; +/** + * @internal + * @hidden + */ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { const { navId } = menu; const { MenuGroup, Menu: ContextMenu } = getByProps< @@ -136,20 +140,19 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menuItems[navId].forEach((item) => { try { const itemRet = makeItem(item.getItem(data, menu)) as ContextItem & { - props: { replug?: boolean }; + props: { replug?: boolean; id?: string; }; }; - // removed the code to add unique id every time because it made experience bad while hovering over item and it getting updated - // should be fine because we actively keep removing old items ig - if (itemRet?.props) { // add in prop for cleanup itemRet.props.replug = true; + // custom unique id if not added by dev + itemRet.props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}` } menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); } catch (err) { - logger.error("Error while running GetContextItem function", err, item.getItem); + logger.error("Error while running GetContextItem function", err, item.getItem, menu.children.at(item.sectionId)); } }); From 482e3dccf1a28f2a418c4b97b5edf46df0975cb5 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 26 Jul 2023 06:05:23 +0530 Subject: [PATCH 11/34] handle adding props at right place. would add for submenu items too now --- src/renderer/coremods/contextMenu/index.tsx | 27 ++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 2856414dd..486637bd9 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -16,26 +16,35 @@ export const menuItems = {} as Record< Array<{ getItem: GetContextItem; sectionId: number; indexInSection: number }> >; +type RepluggedContextItem = ContextItem & { + props: { replug?: boolean; id?: string; }; +} + /** * Converts data into a React element. Any elements or falsy value will be returned as is * @param raw The data to convert * @returns The converted item */ -function makeItem(raw: RawContextItem | ContextItem | undefined | void): ContextItem | undefined { +function makeItem(raw: RawContextItem | ContextItem | undefined | void): RepluggedContextItem | undefined { // Occasionally React won't be loaded when this function is ran, so we don't return anything if (!React) return undefined; if (!raw) { // If something falsy is passed, let it through // Discord just skips over them too - return raw as ContextItem | undefined; + return raw as undefined; } if (React.isValidElement(raw)) { // We can't construct something that's already made - return raw as ContextItem | undefined; + // apparently you can but we ain't gonna do that because states will get messed up. + return raw as RepluggedContextItem; } const { type, ...props } = raw; + // add in prop for cleanup + props.replug = true; + // custom unique id if not added by dev + props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; if (props.children) { props.children = props.children.map((child: RawContextItem | ContextItem | undefined) => makeItem(child), @@ -139,17 +148,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //adding new items menuItems[navId].forEach((item) => { try { - const itemRet = makeItem(item.getItem(data, menu)) as ContextItem & { - props: { replug?: boolean; id?: string; }; - }; - - if (itemRet?.props) { - // add in prop for cleanup - itemRet.props.replug = true; - // custom unique id if not added by dev - itemRet.props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}` - } - + const itemRet = makeItem(item.getItem(data, menu)); menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); } catch (err) { logger.error("Error while running GetContextItem function", err, item.getItem, menu.children.at(item.sectionId)); From 9c172c422950f591ea4c3af6dec30e4b708fac14 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 26 Jul 2023 06:06:33 +0530 Subject: [PATCH 12/34] pretty now? --- src/renderer/coremods/contextMenu/index.tsx | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 486637bd9..7765ca3a2 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -17,15 +17,17 @@ export const menuItems = {} as Record< >; type RepluggedContextItem = ContextItem & { - props: { replug?: boolean; id?: string; }; -} + props: { replug?: boolean; id?: string }; +}; /** * Converts data into a React element. Any elements or falsy value will be returned as is * @param raw The data to convert * @returns The converted item */ -function makeItem(raw: RawContextItem | ContextItem | undefined | void): RepluggedContextItem | undefined { +function makeItem( + raw: RawContextItem | ContextItem | undefined | void, +): RepluggedContextItem | undefined { // Occasionally React won't be loaded when this function is ran, so we don't return anything if (!React) return undefined; @@ -41,10 +43,10 @@ function makeItem(raw: RawContextItem | ContextItem | undefined | void): Replugg } const { type, ...props } = raw; - // add in prop for cleanup - props.replug = true; - // custom unique id if not added by dev - props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; + // add in prop for cleanup + props.replug = true; + // custom unique id if not added by dev + props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; if (props.children) { props.children = props.children.map((child: RawContextItem | ContextItem | undefined) => makeItem(child), @@ -148,10 +150,15 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //adding new items menuItems[navId].forEach((item) => { try { - const itemRet = makeItem(item.getItem(data, menu)); + const itemRet = makeItem(item.getItem(data, menu)); menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); } catch (err) { - logger.error("Error while running GetContextItem function", err, item.getItem, menu.children.at(item.sectionId)); + logger.error( + "Error while running GetContextItem function", + err, + item.getItem, + menu.children.at(item.sectionId), + ); } }); From eec81e3193cfd37364d0296380d2bcc5364f7842 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Thu, 27 Jul 2023 02:58:08 +0530 Subject: [PATCH 13/34] handle some more edge cases --- src/renderer/coremods/contextMenu/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 7765ca3a2..655223879 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -38,7 +38,6 @@ function makeItem( } if (React.isValidElement(raw)) { // We can't construct something that's already made - // apparently you can but we ain't gonna do that because states will get messed up. return raw as RepluggedContextItem; } @@ -46,7 +45,7 @@ function makeItem( // add in prop for cleanup props.replug = true; // custom unique id if not added by dev - props.id ??= `repluggedMenuItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; + props.id ??= `repluggedContextItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; if (props.children) { props.children = props.children.map((child: RawContextItem | ContextItem | undefined) => makeItem(child), @@ -114,8 +113,13 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // The data as passed as Arguments from the calling function, so we just grab what we want from it const data = menu.data[0]; + // make children array if it's not already + if (!Array.isArray(menu.children)) { + menu.children = [menu.children]; + } + //Add group only if it doesn't exist - if (!menu.children.some((child) => child?.props?.id === "replugged")) { + if (!menu.children.some?.((child) => child?.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; @@ -139,7 +143,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n ) ? menu.children .at(sectionId) - ?.props.children.filter((child: React.ReactElement) => !child.props.replug) + ?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) : [menu.children.at(sectionId)?.props.children]; } } catch (err) { From 166f4cddea6696a79fcf205dc370d09c5489bab9 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Thu, 27 Jul 2023 03:03:54 +0530 Subject: [PATCH 14/34] dont add falsy values to menu --- src/renderer/coremods/contextMenu/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 655223879..132130c6b 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -155,7 +155,9 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menuItems[navId].forEach((item) => { try { const itemRet = makeItem(item.getItem(data, menu)); - menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); + if (itemRet) { + menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); + } } catch (err) { logger.error( "Error while running GetContextItem function", From 0295196209aa198fdb6ef5aacc0903fdd7e6e29f Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Fri, 28 Jul 2023 04:02:37 +0530 Subject: [PATCH 15/34] requested changes --- src/renderer/coremods/contextMenu/index.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 132130c6b..5d7fe6c81 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -7,7 +7,7 @@ import type { RawContextItem, } from "../../../types/coremods/contextMenu"; import { Logger } from "../../modules/logger"; -import { getByProps } from "../../modules/webpack"; +import { ContextMenu as ContextComponents } from "../../modules/components"; const logger = Logger.api("ContextMenu"); @@ -42,10 +42,6 @@ function makeItem( } const { type, ...props } = raw; - // add in prop for cleanup - props.replug = true; - // custom unique id if not added by dev - props.id ??= `repluggedContextItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; if (props.children) { props.children = props.children.map((child: RawContextItem | ContextItem | undefined) => makeItem(child), @@ -100,9 +96,8 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { */ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { const { navId } = menu; - const { MenuGroup, Menu: ContextMenu } = getByProps< - Record & { Menu: React.FunctionComponent } - >(["Menu", "MenuItem", "MenuGroup"])!; +const {MenuGroup, ContextMenu }: {MenuGroup: React.FC, ContextMenu: React.FC} = ContextComponents; + //return nothing as we weren't able to get ContextMenu component, gets handled in plain text patch if (!ContextMenu) return null; @@ -156,8 +151,12 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n try { const itemRet = makeItem(item.getItem(data, menu)); if (itemRet) { + // adding prop for easy cleanup + itemRet.props.replug = true; + // custom unique id if not added by dev + itemRet.props.id ??= `repluggedItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); - } + } } catch (err) { logger.error( "Error while running GetContextItem function", From bfeb5e19f356daa28424817599ecf045c8d9f16a Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Fri, 28 Jul 2023 04:04:48 +0530 Subject: [PATCH 16/34] prettier --- src/renderer/coremods/contextMenu/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 5d7fe6c81..fc226f7bc 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -96,7 +96,13 @@ type ContextMenuData = ContextMenuProps["ContextMenu"] & { */ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | null { const { navId } = menu; -const {MenuGroup, ContextMenu }: {MenuGroup: React.FC, ContextMenu: React.FC} = ContextComponents; + const { + MenuGroup, + ContextMenu, + }: { + MenuGroup: React.FC; + ContextMenu: React.FC; + } = ContextComponents; //return nothing as we weren't able to get ContextMenu component, gets handled in plain text patch if (!ContextMenu) return null; @@ -154,7 +160,7 @@ const {MenuGroup, ContextMenu }: {MenuGroup: React.FC Date: Sat, 12 Aug 2023 00:24:37 +0530 Subject: [PATCH 17/34] should be it --- src/renderer/coremods/contextMenu/index.tsx | 52 +++++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index fc226f7bc..368757afd 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -13,7 +13,7 @@ const logger = Logger.api("ContextMenu"); export const menuItems = {} as Record< ContextMenuTypes, - Array<{ getItem: GetContextItem; sectionId: number; indexInSection: number }> + Array<{ getItem: GetContextItem; sectionId: number | undefined; indexInSection: number }> >; type RepluggedContextItem = ContextItem & { @@ -42,6 +42,7 @@ function makeItem( } const { type, ...props } = raw; + // add in prop for cleanup if (props.children) { props.children = props.children.map((child: RawContextItem | ContextItem | undefined) => makeItem(child), @@ -62,7 +63,7 @@ function makeItem( export function addContextMenuItem( navId: ContextMenuTypes, getItem: GetContextItem, - sectionId: number, + sectionId: number | undefined, indexInSection: number, ): () => void { if (!menuItems[navId]) menuItems[navId] = []; @@ -120,14 +121,25 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n } //Add group only if it doesn't exist - if (!menu.children.some?.((child) => child?.props?.id === "replugged")) { + if (!menu.children?.some?.((child) => child?.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; // Add in the new menu items right above the DevMode Copy ID // If the user doesn't have DevMode enabled, the new items will be at the bottom - menu.children.splice(-1, 0, repluggedGroup); + const hasCopyId = + menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || + menu.children + .at(-1) + ?.props?.children?.some((c: React.ReactElement) => + c?.props?.id?.startsWith("devmode-copy-id-"), + ); + if (hasCopyId) { + menu.children.splice(-1, 0, repluggedGroup); + } else { + menu.children.push(repluggedGroup); + } } //get sections from where to clean items @@ -138,17 +150,15 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //cleaning old items before adding new ones usedSectionIds.forEach((sectionId) => { try { - if (menu.children.at(sectionId)?.props?.children) { - menu.children.at(sectionId)!.props.children = Array.isArray( - menu.children.at(sectionId)?.props.children, + if (menu.children.at(sectionId!)?.props?.children) { + menu.children.at(sectionId!)!.props.children = Array.isArray( + menu.children.at(sectionId!)?.props.children, ) - ? menu.children - .at(sectionId) - ?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) - : [menu.children.at(sectionId)?.props.children]; + ? menu.children.at(sectionId!)?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) + : [menu.children.at(sectionId!)?.props.children]; } } catch (err) { - logger.error("Error while removing old menu items", err, menu.children.at(sectionId)); + logger.error("Error while removing old menu items", err, menu.children.at(sectionId!)); } }); @@ -160,15 +170,27 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // adding prop for easy cleanup itemRet.props.replug = true; // custom unique id if not added by dev - itemRet.props.id ??= `repluggedItem-${Math.random().toString(36).substring(2)}`; - menu.children.at(item.sectionId)?.props.children?.splice(item.indexInSection, 0, itemRet); + itemRet.props.id ??= `repluggedItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; + const hasCopyId = + menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || + menu.children + .at(-1) + ?.props?.children.some((c: React.ReactElement) => + c?.props?.id?.startsWith("devmode-copy-id-"), + ); + const section = + typeof item.sectionId === "undefined" + ? menu.children.at(hasCopyId ? -2 : -1) + : menu.children.at(item.sectionId); + if (!section) return logger.error("Couldn't find section", item.sectionId, menu.children); + section?.props.children?.splice(item.indexInSection, 0, itemRet); } } catch (err) { logger.error( "Error while running GetContextItem function", err, item.getItem, - menu.children.at(item.sectionId), + menu.children.at(item.sectionId!), ); } }); From c77797fa26611752bd88091cbf855588fabe36c7 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 12 Aug 2023 00:36:53 +0530 Subject: [PATCH 18/34] personality >>> looks --- src/renderer/coremods/contextMenu/index.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 07d61cff5..59efd7201 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -120,23 +120,21 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children = [menu.children]; } - //Add group only if it doesn't exist if (!menu.children?.some?.((child) => child?.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; - // Add in the new menu items right above the DevMode Copy ID // If the user doesn't have DevMode enabled, the new items will be at the bottom const hasCopyId = - menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || - menu.children - .at(-1) - ?.props?.children?.some((c: React.ReactElement) => - c?.props?.id?.startsWith("devmode-copy-id-"), - ); + menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || + menu.children + .at(-1) + ?.props?.children?.some((c: React.ReactElement) => + c?.props?.id?.startsWith("devmode-copy-id-"), + ); if (hasCopyId) { menu.children.splice(-1, 0, repluggedGroup); } else { @@ -156,7 +154,9 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children.at(sectionId!)!.props.children = Array.isArray( menu.children.at(sectionId!)?.props.children, ) - ? menu.children.at(sectionId!)?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) + ? menu.children + .at(sectionId!) + ?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) : [menu.children.at(sectionId!)?.props.children]; } } catch (err) { From 6eae5a511b0fa45086249d9851394cb9e66caeef Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Fri, 22 Sep 2023 04:11:53 +0530 Subject: [PATCH 19/34] okay you asked for it --- src/renderer/coremods/contextMenu/index.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 59efd7201..6a9fa2767 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -85,7 +85,7 @@ export function removeContextMenuItem(navId: ContextMenuTypes, getItem: GetConte } type ContextMenuData = ContextMenuProps["ContextMenu"] & { - children: React.ReactElement[]; + children: React.ReactElement | React.ReactElement[]; data: Array>; navId: ContextMenuTypes; plugged?: boolean; @@ -118,6 +118,9 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // make children array if it's not already if (!Array.isArray(menu.children)) { menu.children = [menu.children]; + if (!Array.isArray(menu.children)) { + return ; + } } //Add group only if it doesn't exist @@ -150,6 +153,9 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //cleaning old items before adding new ones usedSectionIds.forEach((sectionId) => { try { + if (!Array.isArray(menu.children)) { + return; + } if (menu.children.at(sectionId!)?.props?.children) { menu.children.at(sectionId!)!.props.children = Array.isArray( menu.children.at(sectionId!)?.props.children, @@ -160,13 +166,20 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n : [menu.children.at(sectionId!)?.props.children]; } } catch (err) { - logger.error("Error while removing old menu items", err, menu.children.at(sectionId!)); + logger.error( + "Error while removing old menu items", + err, + Array.isArray(menu.children) ? menu.children.at(sectionId!) : null, + ); } }); //adding new items menuItems[navId].forEach((item) => { try { + if (!Array.isArray(menu.children)) { + return; + } const itemRet = makeItem(item.getItem(data, menu)); if (itemRet) { // adding prop for easy cleanup @@ -192,7 +205,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n "Error while running GetContextItem function", err, item.getItem, - menu.children.at(item.sectionId!), + Array.isArray(menu.children) ? menu.children.at(item.sectionId!) : null, ); } }); From eb0ded9e145ce9f3916f3cd52fa4b88880f10b63 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sun, 24 Sep 2023 06:48:29 +0530 Subject: [PATCH 20/34] made it warning instead --- src/renderer/coremods/contextMenu/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 6a9fa2767..c240d15d6 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -166,7 +166,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n : [menu.children.at(sectionId!)?.props.children]; } } catch (err) { - logger.error( + logger.warn( "Error while removing old menu items", err, Array.isArray(menu.children) ? menu.children.at(sectionId!) : null, @@ -197,7 +197,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n typeof item.sectionId === "undefined" ? menu.children.at(hasCopyId ? -2 : -1) : menu.children.at(item.sectionId); - if (!section) return logger.error("Couldn't find section", item.sectionId, menu.children); + if (!section) return logger.warn("Couldn't find section", item.sectionId, menu.children); section?.props.children?.splice(item.indexInSection, 0, itemRet); } } catch (err) { From b372e213dc21d01d24c8f6f075e5635d1d2faa81 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 30 Sep 2023 17:14:05 +0530 Subject: [PATCH 21/34] should pass --- src/renderer/coremods/contextMenu/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index fd2916d65..7def1f089 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -146,11 +146,11 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //get sections from where to clean items const usedSectionIds = menuItems[navId] - .map((item) => item.sectionId) + ?.map((item) => item.sectionId) .filter((item, index, array) => array.indexOf(item) === index); //cleaning old items before adding new ones - usedSectionIds.forEach((sectionId) => { + usedSectionIds?.forEach((sectionId) => { try { if (!Array.isArray(menu.children)) { return; @@ -174,7 +174,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n }); //adding new items - menuItems[navId].forEach((item) => { + menuItems[navId]?.forEach((item) => { try { if (!Array.isArray(menu.children)) { return; From c584a384910bc4da0881dc3cdae1402bb8442949 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 30 Sep 2023 23:46:22 +0530 Subject: [PATCH 22/34] pretty? --- src/renderer/coremods/contextMenu/index.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 7def1f089..6c0dc414b 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -106,10 +106,12 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n } = ContextComponents; //return nothing as we weren't able to get ContextMenu component, gets handled in plain text patch + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!ContextMenu) return null; // No items to insert // Or MenuGroup Component is not available + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!menuItems[navId] || !MenuGroup) return ; // The data as passed as Arguments from the calling function, so we just grab what we want from it @@ -123,7 +125,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n } } //Add group only if it doesn't exist - if (!menu.children?.some?.((child) => child?.props?.id === "replugged")) { + if (!menu.children.some((child) => child.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; @@ -134,8 +136,8 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || menu.children .at(-1) - ?.props?.children?.some((c: React.ReactElement) => - c?.props?.id?.startsWith("devmode-copy-id-"), + ?.props?.children?.some( + (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), ); if (hasCopyId) { menu.children.splice(-1, 0, repluggedGroup); @@ -161,7 +163,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n ) ? menu.children .at(sectionId!) - ?.props.children.filter((child: React.ReactElement) => !child?.props?.replug) + ?.props.children.filter((child: React.ReactElement | null) => !child?.props?.replug) : [menu.children.at(sectionId!)?.props.children]; } } catch (err) { @@ -189,15 +191,18 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || menu.children .at(-1) - ?.props?.children.some((c: React.ReactElement) => - c?.props?.id?.startsWith("devmode-copy-id-"), + ?.props?.children.some( + (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), ); const section = typeof item.sectionId === "undefined" ? menu.children.at(hasCopyId ? -2 : -1) : menu.children.at(item.sectionId); - if (!section) return logger.warn("Couldn't find section", item.sectionId, menu.children); - section?.props.children?.splice(item.indexInSection, 0, itemRet); + if (!section) { + logger.warn("Couldn't find section", item.sectionId, menu.children); + return; + } + section.props.children?.splice(item.indexInSection, 0, itemRet); } } catch (err) { logger.error( From d8eb887492ce85b7c48f3a2b7e02bc22e3d1caec Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Mon, 23 Oct 2023 10:41:37 +0530 Subject: [PATCH 23/34] better plain text patch --- src/renderer/coremods/contextMenu/index.tsx | 2 +- src/renderer/coremods/contextMenu/plaintextPatches.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 6c0dc414b..c0c8ee9db 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -107,7 +107,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n //return nothing as we weren't able to get ContextMenu component, gets handled in plain text patch // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (!ContextMenu) return null; + if (!ContextMenu || menu.plugged) return null; // No items to insert // Or MenuGroup Component is not available diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index 2ec99e9fa..59b8e3c39 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -7,10 +7,11 @@ export default [ { match: /var \w,\w=(.)\.navId/, replace: (vars, menu) => - `if (!${menu}.plugged){` + - `const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});` + - `if (patchedMenu!==null){return patchedMenu}` + - `}${vars}`, + `const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});${vars}`, + }, + { + match: /(return)(\(0,.\.jsx.{50,72}\(\)\.menu)/, + replace: (_, prefix, suffix) => `${prefix} patchedMenu?patchedMenu:${suffix}`, }, ], }, From 9b6756029412ed020650553ec22d115313fe963b Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Thu, 2 Nov 2023 23:35:30 +0530 Subject: [PATCH 24/34] fixed for unswc --- .../coremods/contextMenu/plaintextPatches.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index 59b8e3c39..c8d00880d 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -5,22 +5,22 @@ export default [ find: 'Error("Menu', replacements: [ { - match: /var \w,\w=(.)\.navId/, - replace: (vars, menu) => - `const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});${vars}`, + match: /((\w+)\){)(var\s*\w+;let{navId:)/, + replace: (_, prefix, menu, suffix) => + `${prefix}const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});${suffix}`, }, { - match: /(return)(\(0,.\.jsx.{50,72}\(\)\.menu)/, + match: /(patchedMenu.{2400,2600}return)(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, replace: (_, prefix, suffix) => `${prefix} patchedMenu?patchedMenu:${suffix}`, }, ], }, { - find: "navId:", + find: ".Menu,{", replacements: [ { - match: /navId:[\w"-]+,/g, - replace: (navId) => `${navId}data:arguments,`, + match: /\.Menu,{/g, + replace: (prefix) => `${prefix}data:arguments,`, }, ], }, From 8bff7ac641701e456df5688b6585ac7387634e6a Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Thu, 2 Nov 2023 23:37:58 +0530 Subject: [PATCH 25/34] idk --- src/renderer/coremods/contextMenu/plaintextPatches.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index db66e2753..c8d00880d 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -7,15 +7,11 @@ export default [ { match: /((\w+)\){)(var\s*\w+;let{navId:)/, replace: (_, prefix, menu, suffix) => -<<<<<<< HEAD `${prefix}const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});${suffix}`, }, { match: /(patchedMenu.{2400,2600}return)(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, replace: (_, prefix, suffix) => `${prefix} patchedMenu?patchedMenu:${suffix}`, -======= - `${prefix}replugged.coremods.coremods.contextMenu._insertMenuItems(${menu});${suffix}`, ->>>>>>> e6dc5f6e17159dce8ffba344c35a8187a39edb4b }, ], }, From ea82bd353b2683514e173d257c4475dc1f30deea Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Mon, 6 Nov 2023 01:17:02 +0530 Subject: [PATCH 26/34] fixed me dumb dumb --- src/renderer/coremods/contextMenu/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index c0c8ee9db..3f32292a6 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -144,6 +144,16 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n } else { menu.children.push(repluggedGroup); } + } else { + const hasCopyId = + menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || + menu.children + .at(-1) + ?.props?.children?.some( + (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), + ); + //clear replugged section if it was there already + menu.children.at(hasCopyId ? -2 : -1)!.props.children = []; } //get sections from where to clean items From 9d7ecf96ea3ea18ef6cadfbb5fcf1d7dc57f5e5f Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Tue, 30 Jan 2024 05:58:10 +0530 Subject: [PATCH 27/34] syntx? --- src/renderer/coremods/contextMenu/plaintextPatches.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index c8d00880d..72b6329d4 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -11,7 +11,7 @@ export default [ }, { match: /(patchedMenu.{2400,2600}return)(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, - replace: (_, prefix, suffix) => `${prefix} patchedMenu?patchedMenu:${suffix}`, + replace: (_, prefix, suffix) => `${prefix} patchedMenu??${suffix}`, }, ], }, From 6a2b0278924dd09a830f4302021f6cddd80ffeee Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 21 Feb 2024 11:52:53 +0530 Subject: [PATCH 28/34] pnpm replug --- src/renderer/coremods/contextMenu/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 3f32292a6..c3849c912 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -125,7 +125,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n } } //Add group only if it doesn't exist - if (!menu.children.some((child) => child.props?.id === "replugged")) { + if (!menu.children.some?.((child) => child.props?.id === "replugged")) { const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; @@ -136,7 +136,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || menu.children .at(-1) - ?.props?.children?.some( + ?.props?.children?.some?.( (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), ); if (hasCopyId) { From 99a50bae847651865ae2c00d7357c7fd430eb4e9 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 21 Feb 2024 12:22:51 +0530 Subject: [PATCH 29/34] better? --- src/renderer/coremods/contextMenu/index.tsx | 40 ++++++------------- .../coremods/contextMenu/plaintextPatches.ts | 10 ++--- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index c3849c912..dac1d819e 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -120,38 +120,29 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // make children array if it's not already if (!Array.isArray(menu.children)) { menu.children = [menu.children]; - if (!Array.isArray(menu.children)) { - return ; - } } - //Add group only if it doesn't exist - if (!menu.children.some?.((child) => child.props?.id === "replugged")) { + + // For Adding in the new menu items right above the DevMode Copy ID + // If the user doesn't have DevMode enabled, the new items will be at the bottom + const hasCopyId = + menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || + menu.children + .at(-1) + ?.props?.children?.some?.( + (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), + ); + if (!menu.children.some((child) => child.props?.id === "replugged")) { + //Add group only if it doesn't exist const repluggedGroup = ; repluggedGroup.props.id = "replugged"; repluggedGroup.props.children = []; - // Add in the new menu items right above the DevMode Copy ID - // If the user doesn't have DevMode enabled, the new items will be at the bottom - const hasCopyId = - menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || - menu.children - .at(-1) - ?.props?.children?.some?.( - (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), - ); if (hasCopyId) { menu.children.splice(-1, 0, repluggedGroup); } else { menu.children.push(repluggedGroup); } } else { - const hasCopyId = - menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || - menu.children - .at(-1) - ?.props?.children?.some( - (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), - ); //clear replugged section if it was there already menu.children.at(hasCopyId ? -2 : -1)!.props.children = []; } @@ -197,13 +188,6 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n itemRet.props.replug = true; // custom unique id if not added by dev itemRet.props.id ??= `repluggedItem-${Number(`0.${Date.now()}`).toString(36).substring(2)}`; - const hasCopyId = - menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || - menu.children - .at(-1) - ?.props?.children.some( - (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), - ); const section = typeof item.sectionId === "undefined" ? menu.children.at(hasCopyId ? -2 : -1) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index 72b6329d4..be44892b0 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -5,13 +5,9 @@ export default [ find: 'Error("Menu', replacements: [ { - match: /((\w+)\){)(var\s*\w+;let{navId:)/, - replace: (_, prefix, menu, suffix) => - `${prefix}const patchedMenu=replugged.coremods.coremods.contextMenu._buildPatchedMenu(${menu});${suffix}`, - }, - { - match: /(patchedMenu.{2400,2600}return)(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, - replace: (_, prefix, suffix) => `${prefix} patchedMenu??${suffix}`, + match: /return(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, + replace: (_, suffix) => + `return replugged.coremods.coremods.contextMenu._buildPatchedMenu(arguments[0])??${suffix}`, }, ], }, From 4df27da3f9dcb3d94232113db9113fe747a1aac0 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 21 Feb 2024 12:23:26 +0530 Subject: [PATCH 30/34] better? --- src/renderer/apis/settings.ts | 4 ++-- src/renderer/coremods/commands/commands.ts | 8 ++++---- src/renderer/coremods/commands/index.ts | 4 ++-- src/renderer/coremods/settings/pages/Updater.tsx | 5 +++-- src/renderer/util.ts | 13 +++++++------ 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/renderer/apis/settings.ts b/src/renderer/apis/settings.ts index 93708dd52..2cdfd9a51 100644 --- a/src/renderer/apis/settings.ts +++ b/src/renderer/apis/settings.ts @@ -57,8 +57,8 @@ export class SettingsManager, D extends ke ): K extends D ? NonNullable : F extends null | undefined - ? T[K] | undefined - : NonNullable | F { + ? T[K] | undefined + : NonNullable | F { if (typeof this.#settings === "undefined") { throw new Error(`Settings not loaded for namespace ${this.namespace}`); } diff --git a/src/renderer/coremods/commands/commands.ts b/src/renderer/coremods/commands/commands.ts index 7665c1f12..7377fe0f0 100644 --- a/src/renderer/coremods/commands/commands.ts +++ b/src/renderer/coremods/commands/commands.ts @@ -351,8 +351,8 @@ export function loadCommands(): void { listType === "enabled" ? enabledString : listType === "disabled" - ? disabledString - : `${enabledString}\n\n${disabledString}`; + ? disabledString + : `${enabledString}\n\n${disabledString}`; return { send, @@ -383,8 +383,8 @@ export function loadCommands(): void { listType === "enabled" ? enabledString : listType === "disabled" - ? disabledString - : `${enabledString}\n\n${disabledString}`; + ? disabledString + : `${enabledString}\n\n${disabledString}`; return { send, diff --git a/src/renderer/coremods/commands/index.ts b/src/renderer/coremods/commands/index.ts index 3db259d1e..4836625d0 100644 --- a/src/renderer/coremods/commands/index.ts +++ b/src/renderer/coremods/commands/index.ts @@ -217,8 +217,8 @@ async function injectApplicationCommandSearchStore(): Promise { ); if (!commandAndSectionsArray.length) return; if ( - !commandAndSectionsArray.every((commandAndSection) => - res?.some((section) => section.id === commandAndSection.section.id), + !commandAndSectionsArray.every( + (commandAndSection) => res?.some((section) => section.id === commandAndSection.section.id), ) ) { const sectionsToAdd = commandAndSectionsArray diff --git a/src/renderer/coremods/settings/pages/Updater.tsx b/src/renderer/coremods/settings/pages/Updater.tsx index 9473d39c7..f56d2b97d 100644 --- a/src/renderer/coremods/settings/pages/Updater.tsx +++ b/src/renderer/coremods/settings/pages/Updater.tsx @@ -22,8 +22,9 @@ const logger = Logger.coremod("Settings:Updater"); export const Updater = (): React.ReactElement => { const [checking, setChecking] = React.useState(false); - const [updatesAvailable, setUpdatesAvailable] = - React.useState>(getAvailableUpdates()); + const [updatesAvailable, setUpdatesAvailable] = React.useState< + Array + >(getAvailableUpdates()); const [updatePromises, setUpdatePromises] = React.useState>>({}); const [didInstallAll, setDidInstallAll] = React.useState(false); const [lastChecked, setLastChecked] = useSettingArray(updaterSettings, "lastChecked"); diff --git a/src/renderer/util.ts b/src/renderer/util.ts index b086517fc..e3bd99c2b 100644 --- a/src/renderer/util.ts +++ b/src/renderer/util.ts @@ -197,8 +197,8 @@ export function useSetting< value: K extends D ? NonNullable : F extends null | undefined - ? T[K] | undefined - : NonNullable | F; + ? T[K] | undefined + : NonNullable | F; onChange: (newValue: ValType) => void; } { const initial = settings.get(key, fallback); @@ -237,8 +237,8 @@ export function useSettingArray< K extends D ? NonNullable : F extends null | undefined - ? T[K] | undefined - : NonNullable | F, + ? T[K] | undefined + : NonNullable | F, (newValue: ValType) => void, ] { const { value, onChange } = useSetting(settings, key, fallback); @@ -256,8 +256,9 @@ type UnionToIntersection = (U extends never ? never : (k: U) => void) extends type ObjectType = Record; -type ExtractObjectType = - O extends Array ? UnionToIntersection : never; +type ExtractObjectType = O extends Array + ? UnionToIntersection + : never; export function virtualMerge(...objects: O): ExtractObjectType { const fallback = {}; From 50bc857e59bef416cb57d11c2b5fd4281a030adc Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 28 Feb 2024 21:58:54 +0530 Subject: [PATCH 31/34] type fix --- src/renderer/coremods/contextMenu/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index dac1d819e..811af1ccb 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -85,7 +85,7 @@ export function removeContextMenuItem(navId: ContextMenuTypes, getItem: GetConte } type ContextMenuData = ContextMenuProps["ContextMenu"] & { - children: React.ReactElement | React.ReactElement[]; + children: React.ReactElement | Array | null; data: Array>; navId: ContextMenuTypes; plugged?: boolean; @@ -131,7 +131,7 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n ?.props?.children?.some?.( (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), ); - if (!menu.children.some((child) => child.props?.id === "replugged")) { + if (!menu.children.some((child) => child?.props?.id === "replugged")) { //Add group only if it doesn't exist const repluggedGroup = ; repluggedGroup.props.id = "replugged"; From 8254073477e14f3ce264e027c751b57e9a3a997f Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Fri, 21 Jun 2024 11:27:15 +0530 Subject: [PATCH 32/34] fix --- src/renderer/coremods/contextMenu/plaintextPatches.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/plaintextPatches.ts b/src/renderer/coremods/contextMenu/plaintextPatches.ts index be44892b0..59b34151f 100644 --- a/src/renderer/coremods/contextMenu/plaintextPatches.ts +++ b/src/renderer/coremods/contextMenu/plaintextPatches.ts @@ -2,10 +2,10 @@ import type { PlaintextPatch } from "src/types"; export default [ { - find: 'Error("Menu', + find: 'Error("Menu API', replacements: [ { - match: /return(\(0,.\.jsx\)\(\w+.OnMenuSelectContext)/, + match: /return(\(0,.\.jsx\)\(\w+\.\w+\.Provider)/, replace: (_, suffix) => `return replugged.coremods.coremods.contextMenu._buildPatchedMenu(arguments[0])??${suffix}`, }, From e9c279e046748f47bb2862e7e3933ecdba89d6a0 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Wed, 26 Jun 2024 17:56:33 +0530 Subject: [PATCH 33/34] pretty --- src/renderer/coremods/contextMenu/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 026886d1f..7599c0b86 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -9,7 +9,6 @@ import type { import { Logger } from "../../modules/logger"; import { ContextMenu as ContextComponents } from "../../modules/components"; - const logger = Logger.api("ContextMenu"); export const menuItems = {} as Record< @@ -115,7 +114,6 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!menuItems[navId] || !MenuGroup) return ; - // The data as passed as Arguments from the calling function, so we just grab what we want from it const data = menu.data[0]; From 6f9d52456984115f31f9093f19d04cc38e41a635 Mon Sep 17 00:00:00 2001 From: Tharki-God Date: Sat, 13 Jul 2024 20:27:24 +0530 Subject: [PATCH 34/34] prettier --- src/renderer/coremods/contextMenu/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/coremods/contextMenu/index.tsx b/src/renderer/coremods/contextMenu/index.tsx index 7599c0b86..3c129a5c4 100644 --- a/src/renderer/coremods/contextMenu/index.tsx +++ b/src/renderer/coremods/contextMenu/index.tsx @@ -128,8 +128,8 @@ export function _buildPatchedMenu(menu: ContextMenuData): React.ReactElement | n menu.children.at(-1)?.props?.children?.props?.id?.startsWith("devmode-copy-id-") || menu.children .at(-1) - ?.props?.children?.some?.( - (c: React.ReactElement | null) => c?.props?.id?.startsWith("devmode-copy-id-"), + ?.props?.children?.some?.((c: React.ReactElement | null) => + c?.props?.id?.startsWith("devmode-copy-id-"), ); if (!menu.children.some((child) => child?.props?.id === "replugged")) { //Add group only if it doesn't exist