mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-09 02:05:28 +00:00
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:
33
src/redux/reducers/themes.ts
Normal file
33
src/redux/reducers/themes.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user