mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
31 lines
596 B
JavaScript
31 lines
596 B
JavaScript
import _ from 'lodash';
|
|
|
|
export default function reducer(state = {
|
|
rows: [],
|
|
items: {},
|
|
}, action) {
|
|
switch (action.type) {
|
|
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_FULFILLED': {
|
|
const { rdocs } = action.payload;
|
|
return {
|
|
...state,
|
|
rows: _.map(rdocs, '_id'),
|
|
items: _.keyBy(rdocs, '_id'),
|
|
};
|
|
}
|
|
case 'SCRATCHPAD_RECORDS_PUSH': {
|
|
const { rdoc } = action.payload;
|
|
return {
|
|
...state,
|
|
rows: [rdoc._id, ...state.rows],
|
|
items: {
|
|
...state.items,
|
|
[rdoc._id]: rdoc,
|
|
},
|
|
};
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
}
|