diff --git a/src/lib/addons/themes/colors/patches/background.tsx b/src/lib/addons/themes/colors/patches/background.tsx index 468c30c..30be8b4 100644 --- a/src/lib/addons/themes/colors/patches/background.tsx +++ b/src/lib/addons/themes/colors/patches/background.tsx @@ -13,28 +13,38 @@ const Messages = findByFilePathLazy("modules/messages/native/Messages.tsx", true function ThemeBackground({ children }: { children: React.ReactNode; }) { useObservable([colorsPref]); - if (!_colorRef.current - || colorsPref.customBackground === "hidden" - || !_colorRef.current.background?.url - || _colorRef.current.background?.blur && (typeof _colorRef.current.background?.blur !== "number") + const background = _colorRef.current?.background; + const url = background?.url; + const blur = background?.blur; + + if ( + !_colorRef.current || + colorsPref.customBackground === "hidden" || + !url ) { return children; } - return - {children} - ; + if (blur !== undefined && typeof blur !== "number") { + return children; + } + + return ( + + {children} + + ); } export default function patchChatBackground() { try { const patches = [ after("render", Messages, (_, ret) => { - if (!_colorRef.current || !_colorRef.current.background?.url) return; + if (!_colorRef.current || !_colorRef.current.background?.url) return ret; const messagesComponent = findInReactTree( ret, @@ -42,17 +52,20 @@ export default function patchChatBackground() { ); if (messagesComponent) { - const flattened = StyleSheet.flatten(messagesComponent.props.style); - const backgroundColor = getChroma()( - flattened.backgroundColor || "black" - ).alpha( - 1 - (_colorRef.current.background?.opacity ?? 1) - ).hex(); + try { + const flattened = StyleSheet.flatten(messagesComponent.props.style); + const backgroundColor = getChroma()( + flattened.backgroundColor || "black" + ).alpha( + 1 - (_colorRef.current.background?.opacity ?? 1) + ).hex(); - messagesComponent.props.style = StyleSheet.flatten([ - messagesComponent.props.style, - { backgroundColor } - ]); + messagesComponent.props.style = StyleSheet.flatten([ + messagesComponent.props.style, + { backgroundColor } + ]); + } catch (e) { + } } return {ret};