mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
31 lines
660 B
JavaScript
31 lines
660 B
JavaScript
export default function reducer(state = {
|
|
input: '',
|
|
output: '',
|
|
rid: null,
|
|
}, action) {
|
|
if (action.type === 'SCRATCHPAD_PRETEST_DATA_CHANGE') {
|
|
const { type, value } = action.payload;
|
|
return {
|
|
...state,
|
|
[type]: value,
|
|
};
|
|
}
|
|
if (action.type === 'SCRATCHPAD_RECORDS_PUSH') {
|
|
const { rdoc } = action.payload;
|
|
if (rdoc._id === state.rid) {
|
|
return {
|
|
...state,
|
|
output: (rdoc.stdout || '') + (rdoc.stderr || ''),
|
|
rid: null,
|
|
};
|
|
}
|
|
}
|
|
if (action.type === 'SCRATCHPAD_POST_PRETEST_FULFILLED') {
|
|
return {
|
|
...state,
|
|
rid: action.payload.rid,
|
|
};
|
|
}
|
|
return state;
|
|
}
|