You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			29 lines
		
	
	
		
			823 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			29 lines
		
	
	
		
			823 B
		
	
	
	
		
			TypeScript
		
	
| import { Dispatch } from '@reduxjs/toolkit';
 | |
| import { switchHtmlToDarkTheme, switchHtmlToLightTheme } from '../../state/ducks/SessionTheme';
 | |
| import { applyTheme, ThemeStateType } from '../../state/ducks/theme';
 | |
| 
 | |
| export async function switchThemeTo(theme: ThemeStateType, dispatch: Dispatch | null) {
 | |
|   await window.setTheme(theme);
 | |
| 
 | |
|   // for now, do not switch to ocean light nor dark theme as the SessionTheme associated with them is not complete
 | |
|   let newTheme: ThemeStateType | null = null;
 | |
| 
 | |
|   switch (theme) {
 | |
|     case 'dark':
 | |
|       switchHtmlToDarkTheme();
 | |
|       newTheme = 'dark';
 | |
|       break;
 | |
|     case 'light':
 | |
|       switchHtmlToLightTheme();
 | |
|       newTheme = 'light';
 | |
|       break;
 | |
| 
 | |
|     default:
 | |
|       window.log.warn('Unsupported theme: ', theme);
 | |
|   }
 | |
| 
 | |
|   if (newTheme) {
 | |
|     dispatch?.(applyTheme(newTheme));
 | |
|   }
 | |
| }
 |