mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-07 11:55:17 +02:00
Pinned Apps
This commit is contained in:
parent
d3c5e2a5ec
commit
fa5c35b619
6 changed files with 90 additions and 12 deletions
|
@ -37,11 +37,36 @@ const getAppsError = (state: State, action: Action): State => {
|
|||
}
|
||||
}
|
||||
|
||||
const pinApp = (state: State, action: Action): State => {
|
||||
const tmpApps = [...state.apps];
|
||||
const changedApp = tmpApps.find((app: App) => app.id === action.payload.id);
|
||||
|
||||
if (changedApp) {
|
||||
changedApp.isPinned = action.payload.isPinned;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
apps: tmpApps
|
||||
}
|
||||
}
|
||||
|
||||
const addAppSuccess = (state: State, action: Action): State => {
|
||||
const tmpApps = [...state.apps, ...action.payload];
|
||||
|
||||
return {
|
||||
...state,
|
||||
apps: tmpApps
|
||||
}
|
||||
}
|
||||
|
||||
const appReducer = (state = initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case ActionTypes.getApps: return getApps(state, action);
|
||||
case ActionTypes.getAppsSuccess: return getAppsSuccess(state, action);
|
||||
case ActionTypes.getAppsError: return getAppsError(state, action);
|
||||
case ActionTypes.pinApp: return pinApp(state, action);
|
||||
case ActionTypes.addAppSuccess: return addAppSuccess(state, action);
|
||||
default: return state;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue