@@ -28,7 +28,7 @@ import { downloadSourcesTable } from "./dexie";
2828import { useSubscription } from "./hooks/use-subscription" ;
2929import { HydraCloudModal } from "./pages/shared-modals/hydra-cloud/hydra-cloud-modal" ;
3030
31- import { injectCustomCss } from "./helpers" ;
31+ import { injectCustomCss , removeCustomCss } from "./helpers" ;
3232import "./app.scss" ;
3333
3434export interface AppProps {
@@ -246,16 +246,26 @@ export function App() {
246246 } ;
247247 } , [ updateRepacks ] ) ;
248248
249- useEffect ( ( ) => {
250- const loadAndApplyTheme = async ( ) => {
251- const activeTheme = await window . electron . getActiveCustomTheme ( ) ;
249+ const loadAndApplyTheme = useCallback ( async ( ) => {
250+ const activeTheme = await window . electron . getActiveCustomTheme ( ) ;
251+ if ( activeTheme ?. code ) {
252+ injectCustomCss ( activeTheme . code ) ;
253+ } else {
254+ removeCustomCss ( ) ;
255+ }
256+ } , [ ] ) ;
252257
253- if ( activeTheme ?. code ) {
254- injectCustomCss ( activeTheme . code ) ;
255- }
256- } ;
258+ useEffect ( ( ) => {
257259 loadAndApplyTheme ( ) ;
258- } , [ ] ) ;
260+ } , [ loadAndApplyTheme ] ) ;
261+
262+ useEffect ( ( ) => {
263+ const unsubscribe = window . electron . onCustomThemeUpdated ( ( ) => {
264+ loadAndApplyTheme ( ) ;
265+ } ) ;
266+
267+ return ( ) => unsubscribe ( ) ;
268+ } , [ loadAndApplyTheme ] ) ;
259269
260270 const playAudio = useCallback ( ( ) => {
261271 const audio = new Audio ( achievementSound ) ;
@@ -273,14 +283,6 @@ export function App() {
273283 } ;
274284 } , [ playAudio ] ) ;
275285
276- useEffect ( ( ) => {
277- const unsubscribe = window . electron . onCssInjected ( ( cssString ) => {
278- injectCustomCss ( cssString ) ;
279- } ) ;
280-
281- return ( ) => unsubscribe ( ) ;
282- } , [ ] ) ;
283-
284286 const handleToastClose = useCallback ( ( ) => {
285287 dispatch ( closeToast ( ) ) ;
286288 } , [ dispatch ] ) ;
0 commit comments