Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
[Fix] Support 211203 (#212)
Browse files Browse the repository at this point in the history
* Fix 211203

* just to be safe

* themes fix
  • Loading branch information
pylixonly authored Dec 23, 2023
1 parent 0e48cbc commit 98cecb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/lib/metro/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]), {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 98cecb4

Please sign in to comment.