From 33fea50e0bbb17a5120cea7ee206a02bc9378b49 Mon Sep 17 00:00:00 2001 From: V Date: Thu, 31 Aug 2023 21:11:40 +0200 Subject: [PATCH] Delete ClickableBioLinks - it's now a stock feature --- plugins/ClickableBioLinks/manifest.json | 14 ----- plugins/ClickableBioLinks/src/index.tsx | 68 ---------------------- plugins/ClickableBioLinks/src/settings.tsx | 17 ------ 3 files changed, 99 deletions(-) delete mode 100644 plugins/ClickableBioLinks/manifest.json delete mode 100644 plugins/ClickableBioLinks/src/index.tsx delete mode 100644 plugins/ClickableBioLinks/src/settings.tsx diff --git a/plugins/ClickableBioLinks/manifest.json b/plugins/ClickableBioLinks/manifest.json deleted file mode 100644 index 810294d..0000000 --- a/plugins/ClickableBioLinks/manifest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "BetterBios", - "description": "Makes bio text selectable and links in them clickable", - "authors": [ - { - "name": "Vendicated", - "id": "343383572805058560" - } - ], - "main": "src/index.tsx", - "vendetta": { - "icon": "ic_profile_24px" - } -} diff --git a/plugins/ClickableBioLinks/src/index.tsx b/plugins/ClickableBioLinks/src/index.tsx deleted file mode 100644 index 7f4177d..0000000 --- a/plugins/ClickableBioLinks/src/index.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { findByNameAll, findByProps } from "@vendetta/metro"; -import { ReactNative, url as URLOpener, clipboard } from "@vendetta/metro/common"; -import { storage } from "@vendetta/plugin"; -import { getAssetIDByName } from "@vendetta/ui/assets"; -import { showToast } from "@vendetta/ui/toasts"; -import { after, unpatchAll } from "~/shared/vendetta-wrappers"; - -function lazy(fn: () => T) { - let v: T; - return () => (v ??= fn()); -} - -const findActionShitter = lazy(() => findByProps("hideActionSheet")); -const findClipboardAsset = lazy(() => getAssetIDByName("ic_message_copy")); - -function walkReactTree(root: any, visit: (node: any) => void) { - if (!root) return; - - visit(root); - if (!root?.props?.children) return; - - if (Array.isArray(root.props.children)) { - for (const child of root.props.children) { - walkReactTree(child, visit); - } - } else { - walkReactTree(root.props.children, visit); - } -} - -// WHY DOES DISCORD HAVE TWO OF THESE IM GONNA EXPLODE -for (const BioText of findByNameAll("BioText", false)) { - after("default", BioText, ([props], res) => { - if (!res?.props?.children) return; - - // make bio text selectable - res.props.selectable = true; - - walkReactTree(res, node => { - if (node.props?.accessibilityRole === "link") { - const url = node.props.children?.[0]; - if (typeof url !== "string") return; - - node.props.onPress = () => { - URLOpener.openURL(url); - if (storage.dismiss !== false) findActionShitter().hideActionSheet(); - }; - } - }); - - return; - // explode - return ( - { - clipboard.setString(props.bio); - showToast("Copied bio to clipboard", findClipboardAsset()); - }} - > - {res} - - ); - }); -} - -export const onUnload = () => unpatchAll(); - -export { default as settings } from "./settings"; diff --git a/plugins/ClickableBioLinks/src/settings.tsx b/plugins/ClickableBioLinks/src/settings.tsx deleted file mode 100644 index bf9ec22..0000000 --- a/plugins/ClickableBioLinks/src/settings.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { storage } from "@vendetta/plugin"; -import { useProxy } from "@vendetta/storage"; -import { Forms } from "@vendetta/ui/components"; - -export default function Settings() { - useProxy(storage); - - return ( - (storage.dismiss = v)} - note="" - /> - ); -}