From 98cecb4b6a4d9003d360fc150160f2b62eb26c80 Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+amsyarasyiq@users.noreply.github.com> Date: Sat, 23 Dec 2023 12:19:39 +0800 Subject: [PATCH] [Fix] Support 211203 (#212) * Fix 211203 * just to be safe * themes fix --- src/lib/metro/common.ts | 4 +++- src/lib/themes.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/metro/common.ts b/src/lib/metro/common.ts index 5724c93..5ab81f6 100644 --- a/src/lib/metro/common.ts +++ b/src/lib/metro/common.ts @@ -4,11 +4,13 @@ import { ReactNative as RN } from "@lib/preinit"; import type { StyleSheet } from "react-native"; const ThemeStore = findByStoreName("ThemeStore"); -const colorResolver = findByProps("colors", "meta").meta; +const colorModule = findByProps("colors", "unsafe_rawColors"); +const colorResolver = colorModule?.internal ?? colorModule?.meta; // Reimplementation of Discord's createThemedStyleSheet, which was removed since 204201 // Not exactly a 1:1 reimplementation, but sufficient to keep compatibility with existing plugins function createThemedStyleSheet>(sheet: T) { + if (!colorModule) return; for (const key in sheet) { // @ts-ignore sheet[key] = new Proxy(RN.StyleSheet.flatten(sheet[key]), { diff --git a/src/lib/themes.ts b/src/lib/themes.ts index 50b31f8..15d4003 100644 --- a/src/lib/themes.ts +++ b/src/lib/themes.ts @@ -196,7 +196,7 @@ export async function initThemes() { } }); - instead("resolveSemanticColor", color.default.meta, (args, orig) => { + instead("resolveSemanticColor", color.default.meta ?? color.default.internal, (args, orig) => { if (!selectedTheme) return orig(...args); const [theme, propIndex] = args;