[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
1.2 KiB

import { Reducer } from 'redux'
import { ListsActions } from '../actions/lists'
import { EntityListsState, EntityList } from '../types'
const initialState: EntityListsState = {}
const reducer: Reducer<EntityListsState, ListsActions> = (state = initialState, action) => {
switch (action.type) {
case 'LISTS_APPEND':
const list = state[action.payload.key] || {
entities: [],
continuation: undefined,
checked: 0,
}
return {
...state,
[action.payload.key]: {
entities: [
...list.entities,
...action.payload.entities,
],
continuation: action.payload.continuation,
checked: Date.now(),
},
}
case 'LISTS_SET':
return {
...state,
[action.payload.key]: {
entities: action.payload.entities,
continuation: action.payload.continuation,
checked: Date.now(),
}
}
default:
return state
}
}
export default reducer