From 9a98225dd7147fcaa71e6c35c3237617c4d3d2ca Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:37:50 +0800 Subject: [PATCH] directly import `react` & `react-native` --- build.mjs | 5 +- plugins/Last.fm/src/Settings.tsx | 8 +- plugins/NoAutoReplyMention/src/Settings.tsx | 13 +- plugins/RichPresence/src/Settings.tsx | 269 ++++++++++---------- 4 files changed, 149 insertions(+), 146 deletions(-) diff --git a/build.mjs b/build.mjs index 8ba73fb..25596ca 100644 --- a/build.mjs +++ b/build.mjs @@ -73,10 +73,7 @@ async function buildPlugin(plugin) { }, plugins: [ nodeResolve({ - resolveOnly: (id) => ![ - "react", - "react-native" - ].includes(id) + resolveOnly: (id) => !["react", "react-native"].includes(id) }), commonjs(), { diff --git a/plugins/Last.fm/src/Settings.tsx b/plugins/Last.fm/src/Settings.tsx index c4f17e5..8c96d71 100644 --- a/plugins/Last.fm/src/Settings.tsx +++ b/plugins/Last.fm/src/Settings.tsx @@ -1,4 +1,4 @@ -import { NavigationNative, React, ReactNative } from "@vendetta/metro/common"; +import { NavigationNative, React } from "@vendetta/metro/common"; import { storage } from "@vendetta/plugin"; import { useProxy } from "@vendetta/storage"; import { getAssetIDByName } from "@vendetta/ui/assets"; @@ -9,7 +9,9 @@ import { currentSettings } from "."; import Constants from "./constants"; import { initialize } from "./utils"; -const { ScrollView, TouchableOpacity, Text } = ReactNative; +import { useEffect } from "react"; +import { ScrollView, Text, TouchableOpacity } from "react-native"; + const { FormInput, FormDivider, FormSwitchRow, FormText, FormIcon } = Forms; function UpdateButton() { @@ -35,7 +37,7 @@ export default function Settings() { const settings = useProxy(storage) as PluginSettings; const navigation = NavigationNative.useNavigation(); - React.useEffect(() => { + useEffect(() => { navigation.setOptions({ title: "Last.fm Configuration", headerRight: UpdateButton diff --git a/plugins/NoAutoReplyMention/src/Settings.tsx b/plugins/NoAutoReplyMention/src/Settings.tsx index cc5f444..4cb752d 100644 --- a/plugins/NoAutoReplyMention/src/Settings.tsx +++ b/plugins/NoAutoReplyMention/src/Settings.tsx @@ -1,13 +1,14 @@ import { findByStoreName } from "@vendetta/metro"; -import { NavigationNative, React, ReactNative, stylesheet } from "@vendetta/metro/common"; +import { NavigationNative, React, stylesheet } from "@vendetta/metro/common"; import { useProxy } from "@vendetta/storage"; import { getAssetIDByName } from "@vendetta/ui/assets"; import { Forms } from "@vendetta/ui/components"; -import { settings, SettingsSchema } from "."; +import { useEffect, useState } from "react"; +import { FlatList, Image, ScrollView, TouchableOpacity } from "react-native"; +import { SettingsSchema, settings } from "."; const UserStore = findByStoreName("UserStore"); -const { ScrollView, TouchableOpacity, Image, FlatList } = ReactNative; const { FormInput, FormDivider, FormText, FormIcon, FormRow, FormSection, FormSwitchRow } = Forms; const styles = stylesheet.createThemedStyleSheet({ @@ -28,7 +29,7 @@ function AddButton({ callback }: { callback: () => void }) { } function AddRow({ onFinish }: { onFinish: () => void }) { - const [value, setValue] = React.useState(""); + const [value, setValue] = useState(""); const onPressCallback = () => { if (!isNaN(parseInt(value)) && UserStore.getUser(value) && !settings.exempted.includes(value)) { @@ -61,10 +62,10 @@ function AddRow({ onFinish }: { onFinish: () => void }) { export default function Settings() { useProxy(settings) as SettingsSchema; - const [shouldShowAdd, setShouldShowAdd] = React.useState(false); + const [shouldShowAdd, setShouldShowAdd] = useState(false); const navigation = NavigationNative.useNavigation(); - React.useEffect(() => { + useEffect(() => { navigation.setOptions({ headerRight: () => setShouldShowAdd(true)} /> }); diff --git a/plugins/RichPresence/src/Settings.tsx b/plugins/RichPresence/src/Settings.tsx index 910ffd8..8e703c1 100644 --- a/plugins/RichPresence/src/Settings.tsx +++ b/plugins/RichPresence/src/Settings.tsx @@ -1,11 +1,12 @@ -import { React, ReactNative, stylesheet } from "@vendetta/metro/common"; +import { React, stylesheet } from "@vendetta/metro/common"; import { storage } from "@vendetta/plugin"; import { useProxy } from "@vendetta/storage"; import { semanticColors } from "@vendetta/ui"; import { Forms } from "@vendetta/ui/components"; +import { ScrollView } from "react-native"; + const { FormSection, FormInput, FormRow, FormSwitch, FormText } = Forms; -const { ScrollView } = ReactNative; const styles = stylesheet.createThemedStyleSheet({ subText: { @@ -22,135 +23,137 @@ const styles = stylesheet.createThemedStyleSheet({ export default function Settings() { const settings = useProxy(storage) as { [key: string]: any }; - return ( - - settings.app_name = v} - /> - settings.application_id = v} - keyboardType="numeric" - /> - settings.type = v} - keyboardType="numeric" - /> - settings.details = v} - /> - settings.state = v} - /> - - - settings.large_image = v} - /> - settings.large_image_text = v} - /> - settings.small_image = v} - /> - settings.small_image_text = v} - /> - - {"Image assets key can be either a Discord app asset's name or a URL to an image."} - - - - settings.enable_timestamps = v} - />} - /> - settings.start_timestamp = v} - keyboardType="numeric" - /> - settings.end_timestamp = v} - keyboardType="numeric" - /> - settings.start_timestamp = String(Date.now())} - trailing={FormRow.Arrow} - /> - - Leaving start timestamp blank will use the time the Discord started. - - - - settings.button1_text = v} - /> - settings.button1_URL = v} - /> - settings.button2_text = v} - /> - settings.button2_URL = v} - /> - - ); + return ( + + + settings.app_name = v} + /> + settings.application_id = v} + keyboardType="numeric" + /> + settings.type = v} + keyboardType="numeric" + /> + settings.details = v} + /> + settings.state = v} + /> + + + settings.large_image = v} + /> + settings.large_image_text = v} + /> + settings.small_image = v} + /> + settings.small_image_text = v} + /> + + {"Image assets key can be either a Discord app asset's name or a URL to an image."} + + + + settings.enable_timestamps = v} + />} + /> + settings.start_timestamp = v} + keyboardType="numeric" + /> + settings.end_timestamp = v} + keyboardType="numeric" + /> + settings.start_timestamp = String(Date.now())} + trailing={FormRow.Arrow} + /> + + Leaving start timestamp blank will use the time the Discord started. + + + + settings.button1_text = v} + /> + settings.button1_URL = v} + /> + settings.button2_text = v} + /> + settings.button2_URL = v} + /> + + + ); }