[Fix] Support 211203 (#212)

* Fix 211203

* just to be safe

* themes fix
This commit is contained in:
pylixonly 2023-12-23 12:19:39 +08:00 committed by GitHub
parent 0e48cbcb9e
commit 98cecb4b6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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<T extends StyleSheet.NamedStyles<T>>(sheet: T) {
if (!colorModule) return;
for (const key in sheet) {
// @ts-ignore
sheet[key] = new Proxy(RN.StyleSheet.flatten(sheet[key]), {

View file

@ -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;