From 0341e9eb2f2cfe2dc2a75773da369746b3c9f724 Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:34:07 +0800 Subject: [PATCH] chore!(components): remove ContextMenu --- src/lib/ui/components/ContextMenu.tsx | 53 --------------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/lib/ui/components/ContextMenu.tsx diff --git a/src/lib/ui/components/ContextMenu.tsx b/src/lib/ui/components/ContextMenu.tsx deleted file mode 100644 index 7f0486f..0000000 --- a/src/lib/ui/components/ContextMenu.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { instead } from "@lib/api/patcher"; -import { lazyDestructure } from "@lib/utils/lazy"; -import { OptionalKeys } from "@lib/utils/types"; -import { findByProps } from "@metro/wrappers"; -import { AccessibilityInfo, Platform, View } from "react-native"; - -const { ContextMenu: _ContextMenu } = lazyDestructure(() => findByProps("ContextMenu")); - -type ContextMenuItem = { - label: string, - iconSource: import("react-native").ImageSourcePropType, - action: () => unknown, - [key: string]: any; -}; - -type ContextMenuProps = { - triggerOnLongPress: boolean; - items: ContextMenuItem[] | ContextMenuItem[][]; - align: OptionalKeys<["left", "right", "above", "below", "auto"]>; - title: string; - children: React.FC; - [key: string]: any; -}; - -export default function ContextMenu(props: ContextMenuProps) { - const ref = React.useRef(null); - - React.useEffect(() => { - // hacky discord fix for android where pressing back with context menu open crashes the client - if (Platform.OS !== "android") return; - - // @ts-ignore - const ctxMenuReactTag = ref.current?._children?.[0]?._nativeTag; - - return () => { - if (!ctxMenuReactTag) return; - - const unpatch = instead("setAccessibilityFocus", AccessibilityInfo, ([tag], orig) => { - if (tag !== ctxMenuReactTag) { - return orig.apply(AccessibilityInfo, [tag]); - } else { - unpatch(); // and skip this call - } - }); - }; - }, []); - - return - <_ContextMenu - {...props} - /> - ; -}