diff --git a/src/ui/settings/components/InstallButton.tsx b/src/ui/settings/components/InstallButton.tsx index 02f2f08..9bf55bb 100644 --- a/src/ui/settings/components/InstallButton.tsx +++ b/src/ui/settings/components/InstallButton.tsx @@ -1,5 +1,5 @@ import { ReactNative as RN, stylesheet, clipboard } from "@metro/common"; -import { HTTP_REGEX } from "@lib/constants"; +import { HTTP_REGEX_MULTI } from "@lib/constants"; import { showInputAlert } from "@ui/alerts"; import { getAssetIDByName } from "@ui/assets"; import { semanticColors } from "@ui/color"; @@ -8,7 +8,7 @@ const styles = stylesheet.createThemedStyleSheet({ icon: { marginRight: 10, tintColor: semanticColors.HEADER_PRIMARY, - } + }, }); interface InstallButtonProps { @@ -22,15 +22,15 @@ export default function InstallButton({ alertTitle, installFunction: fetchFuncti clipboard.getString().then((content) => showInputAlert({ title: alertTitle, - initialValue: HTTP_REGEX.test(content) ? content : "", + initialValue: content.match(HTTP_REGEX_MULTI)?.[0] ?? "", placeholder: "https://example.com/", onConfirm: (input: string) => fetchFunction(input), confirmText: "Install", - cancelText: "Cancel" + cancelText: "Cancel", }) ) }> ); -} \ No newline at end of file +} diff --git a/src/ui/settings/data.tsx b/src/ui/settings/data.tsx index 686b6d3..b064cf0 100644 --- a/src/ui/settings/data.tsx +++ b/src/ui/settings/data.tsx @@ -11,10 +11,13 @@ import General from "@ui/settings/pages/General"; import Plugins from "@ui/settings/pages/Plugins"; import Themes from "@ui/settings/pages/Themes"; import Developer from "@ui/settings/pages/Developer"; +import { PROXY_PREFIX } from "@/lib/constants"; +import { showConfirmationAlert } from "../alerts"; +import { showToast } from "../toasts"; interface Screen { [index: string]: any; - key: string, + key: string; title: string; icon?: string; shouldRender?: () => boolean; @@ -41,7 +44,25 @@ export const getScreens = (youKeys = false): Screen[] => [ title: "Plugins", icon: "debug", options: { - headerRight: () => , + headerRight: () => ( + { + if (!input.startsWith(PROXY_PREFIX) && !settings.developerSettings) + showConfirmationAlert({ + title: "Unproxied Plugin", + content: "The plugin you are trying to install has not been proxied/verified by Vendetta staff. Are you sure you want to continue?", + confirmText: "Install", + onConfirm: () => + installPlugin(input) + .then(() => showToast("Installed plugin", getAssetIDByName("Check"))) + .catch((x) => showToast(x.toString(), getAssetIDByName("Small"))), + cancelText: "Cancel", + }); + else return await installPlugin(input); + }} + /> + ), }, render: Plugins, }, @@ -67,22 +88,22 @@ export const getScreens = (youKeys = false): Screen[] => [ key: formatKey("VendettaCustomPage", youKeys), title: "Vendetta Page", shouldRender: () => false, - render: ({ render: PageView, noErrorBoundary, ...options }: { render: React.ComponentType, noErrorBoundary: boolean } & Record) => { + render: ({ render: PageView, noErrorBoundary, ...options }: { render: React.ComponentType; noErrorBoundary: boolean } & Record) => { const navigation = NavigationNative.useNavigation(); navigation.addListener("focus", () => navigation.setOptions(without(options, "render", "noErrorBoundary"))); - return noErrorBoundary ? : ; - } - } -] + return noErrorBoundary ? : + }, + }, +]; export const getRenderableScreens = (youKeys = false) => getScreens(youKeys).filter(s => s.shouldRender?.() ?? true); -export const getPanelsScreens = () => keyMap(getScreens(), (s => ({ +export const getPanelsScreens = () => keyMap(getScreens(), (s) => ({ title: s.title, render: s.render, ...s.options, -}))); +})); export const getYouData = () => { const screens = getScreens(true); @@ -102,9 +123,9 @@ export const getYouData = () => { getComponent: () => ({ navigation, route }: any) => { navigation.addListener("focus", () => navigation.setOptions(s.options)); // TODO: Some ungodly issue causes the keyboard to automatically close in TextInputs on Android. Why?! - return ; - } - } - })) - } -} \ No newline at end of file + return + }, + }, + })), + }; +};