[Fix] Support 211203 (#212)
* Fix 211203 * just to be safe * themes fix
This commit is contained in:
parent
0e48cbcb9e
commit
98cecb4b6a
2 changed files with 4 additions and 2 deletions
|
@ -4,11 +4,13 @@ import { ReactNative as RN } from "@lib/preinit";
|
||||||
import type { StyleSheet } from "react-native";
|
import type { StyleSheet } from "react-native";
|
||||||
|
|
||||||
const ThemeStore = findByStoreName("ThemeStore");
|
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
|
// Reimplementation of Discord's createThemedStyleSheet, which was removed since 204201
|
||||||
// Not exactly a 1:1 reimplementation, but sufficient to keep compatibility with existing plugins
|
// Not exactly a 1:1 reimplementation, but sufficient to keep compatibility with existing plugins
|
||||||
function createThemedStyleSheet<T extends StyleSheet.NamedStyles<T>>(sheet: T) {
|
function createThemedStyleSheet<T extends StyleSheet.NamedStyles<T>>(sheet: T) {
|
||||||
|
if (!colorModule) return;
|
||||||
for (const key in sheet) {
|
for (const key in sheet) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sheet[key] = new Proxy(RN.StyleSheet.flatten(sheet[key]), {
|
sheet[key] = new Proxy(RN.StyleSheet.flatten(sheet[key]), {
|
||||||
|
|
|
@ -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);
|
if (!selectedTheme) return orig(...args);
|
||||||
|
|
||||||
const [theme, propIndex] = args;
|
const [theme, propIndex] = args;
|
||||||
|
|
Loading…
Reference in a new issue