Fix theme shop themes not applying as a base

- [#217] fixed theme shop themes not applying as a base
- added `themes` state path to store themes locally at
This commit is contained in:
brecert
2021-09-11 15:40:14 -04:00
parent c40e4655f0
commit a02276ec5d
6 changed files with 86 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
import { Theme } from "../../context/Theme";
import { ThemeMetadata } from "../../pages/settings/panes/ThemeShop";
export interface StoredTheme {
slug: string;
meta: ThemeMetadata;
theme: Theme;
}
export type Themes = Record<string, StoredTheme>;
export type ThemesAction =
| { type: undefined }
| { type: "THEMES_SET_THEME"; theme: StoredTheme }
| { type: "THEMES_REMOVE_THEME"; slug: string }
| { type: "RESET" };
export function themes(state: Themes = {}, action: ThemesAction) {
switch (action.type) {
case "THEMES_SET_THEME":
return {
...state,
[action.theme.slug]: action.theme,
};
case "THEMES_REMOVE_THEME":
return { ...state, [action.slug]: null };
case "RESET":
return {};
default:
return state;
}
}