@@ -17,8 +17,7 @@ import type { ThemePreset } from "./types";
1717 * Hook for managing themes including fetching, applying, and custom imports
1818 */
1919export function useThemeManagement ( ) {
20- const { themeState, setThemeState, toggleMode, applyTheme, resetToDefault } =
21- useTheme ( ) ;
20+ const { themeState, toggleMode, applyTheme, resetToDefault } = useTheme ( ) ;
2221 const queryClient = useQueryClient ( ) ;
2322 const [ customThemeUrls , setCustomThemeUrls ] = useState < string [ ] > ( [ ] ) ;
2423
@@ -92,7 +91,7 @@ export function useThemeManagement() {
9291 }
9392 return { theme : fetchedTheme . preset , url, name : fetchedTheme . name } ;
9493 } ,
95- onSuccess : ( { theme, url, name } ) => {
94+ onSuccess : async ( { theme, url, name } ) => {
9695 applyTheme ( theme ) ;
9796
9897 // Add to custom themes if not already there
@@ -101,7 +100,7 @@ export function useThemeManagement() {
101100 }
102101
103102 // Invalidate queries to refresh the lists
104- queryClient . invalidateQueries ( { queryKey : [ "themes" ] } ) ;
103+ await queryClient . invalidateQueries ( { queryKey : [ "themes" ] } ) ;
105104
106105 toast . success ( `Applied theme: ${ name } ` ) ;
107106 } ,
@@ -132,9 +131,9 @@ export function useThemeManagement() {
132131 } ;
133132
134133 // Remove custom theme URL
135- const removeCustomTheme = ( url : string ) => {
134+ const removeCustomTheme = async ( url : string ) => {
136135 setCustomThemeUrls ( ( prev ) => prev . filter ( ( u ) => u !== url ) ) ;
137- queryClient . invalidateQueries ( { queryKey : [ "themes" , "custom" ] } ) ;
136+ await queryClient . invalidateQueries ( { queryKey : [ "themes" , "custom" ] } ) ;
138137 toast . success ( "Removed custom theme" ) ;
139138 } ;
140139
@@ -170,6 +169,6 @@ export function useThemeManagement() {
170169 getThemePreview,
171170
172171 // Errors
173- error : builtInError || customError ,
172+ error : builtInError ?? customError ,
174173 } ;
175174}
0 commit comments