|
@@ -1,10 +1,6 @@
|
|
|
import { createReducer } from '../utils/reducer'
|
|
|
import { has, map, isEqual } from 'lodash'
|
|
|
|
|
|
-const initialState = {
|
|
|
- containers: []
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* @param {*} containers
|
|
@@ -13,14 +9,14 @@ const initialState = {
|
|
|
const setContainers = (containers, action) => {
|
|
|
// single instance
|
|
|
if (has(action.payload, 'container')) {
|
|
|
- return map(containers, c => {
|
|
|
+ containers = map(containers, c => {
|
|
|
return isEqual(c.id, action.payload.container.id) ? action.payload.container : c
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// multiple instances
|
|
|
if (has(action.payload, 'containers')) {
|
|
|
- return action.payload.containers
|
|
|
+ containers = action.payload.containers
|
|
|
}
|
|
|
|
|
|
return containers
|
|
@@ -29,13 +25,13 @@ const setContainers = (containers, action) => {
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
-const containersReducer = createReducer(initialState.containers, {
|
|
|
+const containersReducer = createReducer([], {
|
|
|
'REQUEST_OK': setContainers
|
|
|
})
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
-export const containers = (state = initialState, action) => {
|
|
|
- return containersReducer(state.containers, action)
|
|
|
-}
|
|
|
+export const containers = (state = [], action) => {
|
|
|
+ return containersReducer(state, action)
|
|
|
+}
|