From a8b5beff6ef332b0faff7827504be83bfcf8d5fb Mon Sep 17 00:00:00 2001 From: Beef Date: Sat, 14 Jan 2023 02:39:10 +0000 Subject: [PATCH] [Cleanup] Several small cleanups --- src/lib/debug.ts | 5 +++-- src/lib/metro/filters.ts | 1 + src/lib/plugins.ts | 6 +++--- src/lib/settings.ts | 1 - src/lib/utils/findInReactTree.ts | 8 +++----- src/lib/utils/findInTree.ts | 4 +--- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/lib/debug.ts b/src/lib/debug.ts index ab21372..0caa9a7 100644 --- a/src/lib/debug.ts +++ b/src/lib/debug.ts @@ -45,10 +45,11 @@ export function patchLogHook() { export const versionHash = "__vendettaVersion"; -export function getDebugInfo(string: boolean = false) { +export function getDebugInfo() { const InfoDictionaryManager = RN.NativeModules.InfoDictionaryManager; const hermesProps = window.HermesInternal.getRuntimeProperties(); - const PlatformConstants = RN.Platform.constants; + // TODO: Type 'any' removes errors, but is it sensible? + const PlatformConstants = RN.Platform.constants as any; const rnVer = PlatformConstants.reactNativeVersion; const DCDDeviceManager = RN.NativeModules.DCDDeviceManager; diff --git a/src/lib/metro/filters.ts b/src/lib/metro/filters.ts index 5d226c5..0adcde0 100644 --- a/src/lib/metro/filters.ts +++ b/src/lib/metro/filters.ts @@ -24,6 +24,7 @@ for (const key in window.modules) { } } +// Early find logic const basicFind = (prop: string) => Object.values(window.modules).find(m => m.publicModule.exports?.[prop]).publicModule.exports; // Hoist React diff --git a/src/lib/plugins.ts b/src/lib/plugins.ts index 1eaf067..9819bab 100644 --- a/src/lib/plugins.ts +++ b/src/lib/plugins.ts @@ -2,7 +2,7 @@ import { Indexable, PluginManifest, Plugin } from "@types"; import { navigation } from "@metro/common"; import logger from "@lib/logger"; import createStorage from "@lib/storage"; -import PluginSettings from "@/ui/settings/components/PluginSettings"; +import Subpage from "@/ui/settings/components/Subpage"; type EvaledPlugin = { onLoad?(): void; @@ -126,8 +126,8 @@ export function showSettings(plugin: Plugin) { const settings = getSettings(plugin.id); if (!settings) return logger.error(`Plugin ${plugin.id} is not loaded or has no settings`); - navigation.push(PluginSettings, { - plugin: plugin, + navigation.push(Subpage, { + name: plugin.manifest.name, children: settings, }); } diff --git a/src/lib/settings.ts b/src/lib/settings.ts index c0b12d5..5cc6fd9 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -1,5 +1,4 @@ import createStorage from "@lib/storage"; import { Settings } from "@types"; -// TODO: Switch to using 'any' as type? export default createStorage("VENDETTA_SETTINGS"); \ No newline at end of file diff --git a/src/lib/utils/findInReactTree.ts b/src/lib/utils/findInReactTree.ts index 904b238..027a532 100644 --- a/src/lib/utils/findInReactTree.ts +++ b/src/lib/utils/findInReactTree.ts @@ -1,8 +1,6 @@ import { SearchFilter } from "@types"; import findInTree from "@utils/findInTree"; -export default function findInReactTree(tree: { [key: string]: any }, filter: SearchFilter): any { - return findInTree(tree, filter, { - walkable: ["props", "children", "child", "sibling"], - }); -} \ No newline at end of file +export default (tree: { [key: string]: any }, filter: SearchFilter): any => findInTree(tree, filter, { + walkable: ["props", "children", "child", "sibling"], +}); \ No newline at end of file diff --git a/src/lib/utils/findInTree.ts b/src/lib/utils/findInTree.ts index 1f160dc..449e665 100644 --- a/src/lib/utils/findInTree.ts +++ b/src/lib/utils/findInTree.ts @@ -1,6 +1,4 @@ -/* - Disclaimer: https://github.com/Cordwood/Cordwood/blob/91c0b971bbf05e112927df75415df99fa105e1e7/src/lib/utils/findInTree.ts -*/ +// https://github.com/Cordwood/Cordwood/blob/91c0b971bbf05e112927df75415df99fa105e1e7/src/lib/utils/findInTree.ts import { FindInTreeOptions, SearchFilter } from "@types";