[Global] Code cleanup pass
This commit is contained in:
parent
69c2544b99
commit
7d36903b2c
19 changed files with 47 additions and 73 deletions
|
@ -4,7 +4,7 @@ import InputAlert from "@ui/components/InputAlert";
|
|||
|
||||
const Alerts = findByProps("openLazy", "close");
|
||||
|
||||
interface InternalConfirmationAlertOptions extends Omit<ConfirmationAlertOptions, 'content'> {
|
||||
interface InternalConfirmationAlertOptions extends Omit<ConfirmationAlertOptions, "content"> {
|
||||
content: string | JSX.Element | JSX.Element[] | undefined;
|
||||
body: string | undefined;
|
||||
children: JSX.Element | JSX.Element[];
|
||||
|
@ -20,18 +20,11 @@ export function showConfirmationAlert(options: ConfirmationAlertOptions) {
|
|||
};
|
||||
|
||||
delete internalOptions.content;
|
||||
|
||||
return Alerts.show(internalOptions);
|
||||
};
|
||||
|
||||
export function showCustomAlert(component: React.ComponentType, props: any) {
|
||||
Alerts.openLazy({
|
||||
importer: async function () {
|
||||
return () => React.createElement(component, props);
|
||||
}
|
||||
});
|
||||
};
|
||||
export const showCustomAlert = (component: React.ComponentType, props: any) => Alerts.openLazy({
|
||||
importer: async () => () => React.createElement(component, props),
|
||||
});
|
||||
|
||||
export function showInputAlert(options: InputAlertProps) {
|
||||
showCustomAlert(InputAlert as React.ComponentType, options);
|
||||
};
|
||||
export const showInputAlert = (options: InputAlertProps) => showCustomAlert(InputAlert as React.ComponentType, options);
|
|
@ -1,6 +1,6 @@
|
|||
import { Asset, Indexable } from "@types";
|
||||
import { after } from "@lib/patcher";
|
||||
import { assets } from "@metro/common";
|
||||
import { after } from "@lib/patcher";
|
||||
|
||||
export const all: Indexable<Asset> = {};
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ import { constants } from "@metro/hoist";
|
|||
//* In 167.1, most if not all traces of the old color modules were removed.
|
||||
//* In 168.6, Discord restructured EVERYTHING again. SemanticColor on this module no longer works when passed to a stylesheet. We must now use what you see below.
|
||||
//? However, this is not all bad. The changes made in 168.6 do allow for better native-less theming.
|
||||
const colorModule = findByProps("SemanticColor");
|
||||
const colorModule = findByProps("colors", "meta");
|
||||
|
||||
//* For both below, SemanticColor and RawColor are seemingly not used. Once again, what are Discord doing?
|
||||
|
||||
//? SemanticColor and default.colors are effectively ThemeColorMap
|
||||
export const semanticColors = (constants.ThemeColorMap ?? colorModule?.default?.colors ?? colorModule?.SemanticColor);
|
||||
export const semanticColors = (constants.ThemeColorMap ?? colorModule?.colors);
|
||||
|
||||
//? RawColor and default.unsafe_rawColors are effectively Colors
|
||||
//* Note that constants.Colors does still appear to exist on newer versions despite Discord not internally using it - what the fuck?
|
||||
export const rawColors = (constants.Colors ?? colorModule?.default?.unsafe_rawColors ?? colorModule?.RawColor);
|
||||
export const rawColors = (constants.Colors ?? colorModule?.unsafe_rawColors);
|
|
@ -3,7 +3,6 @@ import { Forms, Alert } from "@ui/components";
|
|||
import { InputAlertProps } from "@types";
|
||||
|
||||
const { FormInput } = Forms;
|
||||
|
||||
const Alerts = findByProps("openLazy", "close");
|
||||
|
||||
export default function InputAlert({ title, confirmText, confirmColor, onConfirm, cancelText, placeholder, initialValue = "" }: InputAlertProps) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Based on https://github.com/Aliucord/AliucordRN/blob/main/src/ui/patchTheme.ts
|
||||
// Literally could not figure this out, many thanks
|
||||
|
||||
import { findByProps, findByStoreName } from "@metro/filters";
|
||||
import { FluxDispatcher } from "@metro/common";
|
||||
import { findByProps, findByStoreName } from "@metro/filters";
|
||||
import logger from "@lib/logger";
|
||||
|
||||
// TODO: Move these to common modules?
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { HTTP_REGEX } from "@/lib/constants";
|
||||
import { semanticColors } from "@ui/color";
|
||||
import { installPlugin } from "@lib/plugins";
|
||||
import { clipboard, stylesheet } from "@metro/common";
|
||||
import { HTTP_REGEX } from "@lib/constants";
|
||||
import { installPlugin } from "@lib/plugins";
|
||||
import { showInputAlert } from "@ui/alerts";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { semanticColors } from "@ui/color";
|
||||
import { General } from "@ui/components";
|
||||
|
||||
const { TouchableOpacity, Image } = General;
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import { ButtonColors, Plugin } from "@types";
|
||||
import { ReactNative as RN, stylesheet, NavigationNative } from "@metro/common";
|
||||
import { findByProps } from "@metro/filters";
|
||||
import { Forms, General } from "@ui/components";
|
||||
import { Plugin } from "@types";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { showToast } from "@ui/toasts";
|
||||
import { showConfirmationAlert } from "@ui/alerts";
|
||||
import { semanticColors } from "@ui/color";
|
||||
import { removePlugin, startPlugin, stopPlugin, getSettings } from "@lib/plugins";
|
||||
import copyText from "@utils/copyText";
|
||||
|
||||
// TODO: Replace with our eventual dialog API
|
||||
const Dialog = findByProps("show", "openLazy", "close");
|
||||
|
||||
const { FormRow, FormSwitch } = Forms;
|
||||
const { TouchableOpacity, Image } = General;
|
||||
|
||||
|
@ -79,12 +76,12 @@ export default function PluginCard({ plugin, index }: PluginCardProps) {
|
|||
trailing={
|
||||
<RN.View style={styles.actions}>
|
||||
<TouchableOpacity
|
||||
onPress={() => Dialog.show({
|
||||
onPress={() => showConfirmationAlert({
|
||||
title: "Wait!",
|
||||
body: `Are you sure you wish to delete ${plugin.manifest.name}?`,
|
||||
content: `Are you sure you wish to delete ${plugin.manifest.name}?`,
|
||||
confirmText: "Delete",
|
||||
cancelText: "Cancel",
|
||||
confirmColor: "red",
|
||||
confirmColor: ButtonColors.RED,
|
||||
onConfirm: () => {
|
||||
try {
|
||||
removePlugin(plugin.id);
|
||||
|
|
|
@ -4,11 +4,11 @@ import { after } from "@lib/patcher";
|
|||
import findInReactTree from "@utils/findInReactTree";
|
||||
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
||||
import SettingsSection from "@ui/settings/components/SettingsSection";
|
||||
import InstallPluginButton from "@ui/settings/components/InstallPluginButton";
|
||||
import General from "@ui/settings/pages/General";
|
||||
import Plugins from "@ui/settings/pages/Plugins";
|
||||
import Developer from "@ui/settings/pages/Developer";
|
||||
import AssetBrowser from "@ui/settings/pages/AssetBrowser";
|
||||
import InstallPluginButton from "@ui/settings/components/InstallPluginButton";
|
||||
|
||||
const screensModule = findByDisplayName("getScreens", false);
|
||||
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ReactNative as RN, stylesheet } from "@metro/common";
|
||||
import { Forms, Search } from "@ui/components";
|
||||
import { all } from "@ui/assets";
|
||||
import { Forms, Search } from "@ui/components";
|
||||
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
||||
import AssetDisplay from "@ui/settings/components/AssetDisplay";
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { ReactNative as RN, NavigationNative } from "@metro/common";
|
||||
import { Forms } from "@ui/components";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { showToast } from "@ui/toasts";
|
||||
import { connectToDebugger } from "@lib/debug";
|
||||
import { useProxy } from "@lib/storage";
|
||||
import settings, { loaderConfig } from "@lib/settings";
|
||||
import logger from "@lib/logger";
|
||||
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
||||
|
||||
const { FormSection, FormRow, FormSwitchRow, FormInput, FormDivider } = Forms;
|
||||
|
@ -37,18 +35,10 @@ export default function Developer() {
|
|||
<FormRow
|
||||
label="Connect to React DevTools"
|
||||
leading={<FormRow.Icon source={getAssetIDByName("ic_badge_staff")} />}
|
||||
onPress={() => {
|
||||
try {
|
||||
window.__vendetta_rdc?.connectToDevTools({
|
||||
host: settings.debuggerUrl.split(":")?.[0],
|
||||
resolveRNStyle: RN.StyleSheet.flatten,
|
||||
});
|
||||
} catch (e) {
|
||||
// TODO: Check if this ever actually catches anything
|
||||
logger.error("Failed to connect to React DevTools!", e);
|
||||
showToast("Failed to connect to React DevTools!", getAssetIDByName("Small"));
|
||||
}
|
||||
}}
|
||||
onPress={() => window.__vendetta_rdc?.connectToDevTools({
|
||||
host: settings.debuggerUrl.split(":")?.[0],
|
||||
resolveRNStyle: RN.StyleSheet.flatten,
|
||||
})}
|
||||
/>
|
||||
</>}
|
||||
</FormSection>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ReactNative as RN, url, invites } from "@metro/common";
|
||||
import { DISCORD_SERVER, GITHUB } from "@lib/constants";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { Forms, Summary } from "@ui/components";
|
||||
import { DISCORD_SERVER, GITHUB } from "@lib/constants";
|
||||
import { getDebugInfo } from "@lib/debug";
|
||||
import { useProxy } from "@lib/storage";
|
||||
import settings from "@lib/settings";
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { toasts } from "@metro/common";
|
||||
|
||||
export function showToast(content: string, asset: number) {
|
||||
return toasts.open({
|
||||
content: content,
|
||||
source: asset,
|
||||
});
|
||||
}
|
||||
export const showToast = (content: string, asset: number) => toasts.open({
|
||||
content: content,
|
||||
source: asset,
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue