1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-02 09:25:17 +02:00

Improved default theme setting. Pushed version 2.0.1

This commit is contained in:
Paweł Malak 2021-11-19 13:24:07 +01:00
parent e0f6034868
commit c2e9f82cd6
5 changed files with 11 additions and 6 deletions

View file

@ -68,7 +68,7 @@ export const App = (): JSX.Element => {
// If there is no user theme, set the default one
useEffect(() => {
if (!loading && !localStorage.theme) {
setTheme(config.defaultTheme);
setTheme(config.defaultTheme, false);
}
}, [loading]);

View file

@ -5,11 +5,15 @@ import { Theme } from '../../interfaces/Theme';
import { themes } from '../../components/Settings/Themer/themes.json';
export const setTheme =
(name: string) => (dispatch: Dispatch<SetThemeAction>) => {
(name: string, remeberTheme: boolean = true) =>
(dispatch: Dispatch<SetThemeAction>) => {
const theme = themes.find((theme) => theme.name === name);
if (theme) {
localStorage.setItem('theme', name);
if (remeberTheme) {
localStorage.setItem('theme', name);
}
loadTheme(theme);
dispatch({