1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-07 03:35:18 +02:00

Added user themes section to Theme settings

This commit is contained in:
Paweł Malak 2022-03-23 16:13:34 +01:00
parent 89bd921875
commit 48e28b9abd
10 changed files with 136 additions and 44 deletions

View file

@ -1,13 +1,16 @@
import { Action } from '../actions';
import { ActionType } from '../action-types';
import { Theme } from '../../interfaces/Theme';
import { arrayPartition } from '../../utility';
interface ThemeState {
themes: Theme[];
userThemes: Theme[];
}
const initialState: ThemeState = {
themes: [],
userThemes: [],
};
export const themeReducer = (
@ -16,7 +19,16 @@ export const themeReducer = (
): ThemeState => {
switch (action.type) {
case ActionType.fetchThemes: {
return { themes: action.payload };
const [themes, userThemes] = arrayPartition<Theme>(
action.payload,
(e) => !e.isCustom
);
return {
...state,
themes,
userThemes,
};
}
default: