fix(themes): fix theme backgrounds for SOME people

This commit is contained in:
cocobo1 2026-01-01 19:59:39 +02:00
parent 390967ca6c
commit 0df137977d
3 changed files with 35 additions and 32 deletions

View file

@ -74,7 +74,7 @@ const config = {
constModules: { constModules: {
globals: { globals: {
"bunny-build-info": { "bunny-build-info": {
version: `"v1.4.0"` version: `"v1.4.1"`
} }
} }
}, },

View file

@ -6,17 +6,18 @@ import { findInReactTree } from "@lib/utils";
import { findByFilePathLazy } from "@metro"; import { findByFilePathLazy } from "@metro";
import chroma from "chroma-js"; import chroma from "chroma-js";
import { ImageBackground, StyleSheet } from "react-native"; import { ImageBackground, StyleSheet } from "react-native";
import { logger } from "@lib/utils/logger";
const Messages = findByFilePathLazy("components_native/chat/Messages.tsx", true); const Messages = findByFilePathLazy("modules/messages/native/Messages.tsx", true);
function ThemeBackground({ children }: { children: React.ReactNode }) { function ThemeBackground({ children }: { children: React.ReactNode; }) {
useObservable([colorsPref]); useObservable([colorsPref]);
if (!_colorRef.current if (!_colorRef.current
|| colorsPref.customBackground === "hidden" || colorsPref.customBackground === "hidden"
|| !_colorRef.current.background?.url || !_colorRef.current.background?.url
|| _colorRef.current.background?.blur && (typeof _colorRef.current.background?.blur !== "number") || _colorRef.current.background?.blur && (typeof _colorRef.current.background?.blur !== "number")
){ ) {
return children; return children;
} }
@ -30,30 +31,36 @@ function ThemeBackground({ children }: { children: React.ReactNode }) {
} }
export default function patchChatBackground() { export default function patchChatBackground() {
const patches = [ try {
after("render", Messages, (_, ret) => { const patches = [
if (!_colorRef.current || !_colorRef.current.background?.url) return; after("render", Messages, (_, ret) => {
const messagesComponent = findInReactTree( if (!_colorRef.current || !_colorRef.current.background?.url) return;
ret,
x => x && "HACK_fixModalInteraction" in x.props && x?.props?.style
);
if (messagesComponent) { const messagesComponent = findInReactTree(
const flattened = StyleSheet.flatten(messagesComponent.props.style); ret,
const backgroundColor = chroma( x => x && "HACK_fixModalInteraction" in x.props && x?.props?.style
flattened.backgroundColor || "black" );
).alpha(
1 - (_colorRef.current.background?.opacity ?? 1)
).hex();
messagesComponent.props.style = StyleSheet.flatten([ if (messagesComponent) {
messagesComponent.props.style, const flattened = StyleSheet.flatten(messagesComponent.props.style);
{ backgroundColor } const backgroundColor = chroma(
]); flattened.backgroundColor || "black"
} ).alpha(
1 - (_colorRef.current.background?.opacity ?? 1)
).hex();
return <ThemeBackground>{ret}</ThemeBackground>; messagesComponent.props.style = StyleSheet.flatten([
}) messagesComponent.props.style,
]; { backgroundColor }
return () => patches.forEach(x => x()); ]);
} }
return <ThemeBackground>{ret}</ThemeBackground>;
})
];
return () => patches.forEach(x => x());
} catch (e) {
logger.error("Failed to patch chat background.", e);
return () => { };
}
}

View file

@ -43,7 +43,6 @@ export async function toggleSafeMode() {
setTimeout(BundleUpdaterManager.reload, 400); setTimeout(BundleUpdaterManager.reload, 400);
} }
// --- Debugger State & Logic ---
let socket: WebSocket | undefined; let socket: WebSocket | undefined;
let originalConsoleLog: any; let originalConsoleLog: any;
let originalConsoleError: any; let originalConsoleError: any;
@ -254,7 +253,6 @@ export function isConnectedToDebugger(): boolean {
return socket?.readyState === WebSocket.OPEN; return socket?.readyState === WebSocket.OPEN;
} }
// --- React DevTools (RDT) Logic ---
const rdtPort = 8097; const rdtPort = 8097;
export let rdtClient: WebSocket | null = null; export let rdtClient: WebSocket | null = null;
export let rdtConnected = false; export let rdtConnected = false;
@ -318,8 +316,6 @@ export function useIsRdtConnected() {
return connected; return connected;
} }
// --- Core Utils ---
/** /**
* @internal * @internal
*/ */