From 9a991a31ba8b596869d578f814b2d6e79f4833df Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Tue, 14 Oct 2025 02:08:22 +0800 Subject: [PATCH] fix: handle empty custom textures (#2221) --- apps/readest-app/src/components/Providers.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/readest-app/src/components/Providers.tsx b/apps/readest-app/src/components/Providers.tsx index 91e418e7..eff1da3d 100644 --- a/apps/readest-app/src/components/Providers.tsx +++ b/apps/readest-app/src/components/Providers.tsx @@ -47,20 +47,17 @@ const Providers = ({ children }: { children: React.ReactNode }) => { if (appService.hasScreenBrightness && brightness >= 0) { setScreenBrightness(brightness / 100); } - const backgroundTextureId = globalViewSettings.backgroundTextureId; - const backgroundOpacity = globalViewSettings.backgroundOpacity; - const backgroundSize = globalViewSettings.backgroundSize; - if (backgroundTextureId && backgroundTextureId !== 'none') { - const customTexture = settings.customTextures.find((t) => t.id === backgroundTextureId); + const textureId = globalViewSettings.backgroundTextureId; + const textureOpacity = globalViewSettings.backgroundOpacity; + const textureSize = globalViewSettings.backgroundSize; + if (textureId && textureId !== 'none') { + document.documentElement.style.setProperty('--bg-texture-opacity', `${textureOpacity}`); + document.documentElement.style.setProperty('--bg-texture-size', textureSize); + const customTexture = settings.customTextures?.find((t) => t.id === textureId); if (customTexture) { addTexture(customTexture.path); } - applyTexture(envConfig, backgroundTextureId); - document.documentElement.style.setProperty( - '--bg-texture-opacity', - backgroundOpacity.toString(), - ); - document.documentElement.style.setProperty('--bg-texture-size', backgroundSize); + applyTexture(envConfig, textureId); } }); }