mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
css-loader 0.28->3.5 del 4.1->5.1 eslint 5.18->6.8 eslint-config-airbnb 17.1->18.1 eslint-loader 2.1->4.0 file-loader 2.0->6.0 fs.extra 8.0->9.0 gulp 2.0->3.0 gulp-nunjucks 4.0->5.0 json-loader 0.5->Removed style-loader 0.23->1.1 uglifyjs-webpack-plugin 1.3->2.2 yargs 13.2->15.3 katex 0.10->0.11 react-monaco-editor 0.35->0.36 timeage-react 1.2->3.0 timeago.js 3.0->4.0 uuid 3.3->7.0
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import _ from 'lodash';
|
|
|
|
export default function reducer(state = {}, action) {
|
|
switch (action.type) {
|
|
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
|
|
const dialogues = action.payload.messages;
|
|
return _.fromPairs(_.map(dialogues, (d) => [d._id, '']));
|
|
}
|
|
case 'DIALOGUES_CREATE': {
|
|
const { id } = action.payload;
|
|
return {
|
|
...state,
|
|
[id]: '',
|
|
};
|
|
}
|
|
case 'DIALOGUES_INPUT_CHANGED': {
|
|
const id = action.meta.dialogueId;
|
|
return {
|
|
...state,
|
|
[id]: action.payload,
|
|
};
|
|
}
|
|
case 'DIALOGUES_POST_REPLY_FULFILLED': {
|
|
const id = action.meta.dialogueId;
|
|
return {
|
|
...state,
|
|
[id]: '',
|
|
};
|
|
}
|
|
case 'DIALOGUES_POST_SEND_FULFILLED': {
|
|
const { placeholderId } = action.meta;
|
|
return {
|
|
..._.omit(state, placeholderId),
|
|
[action.payload.mdoc._id]: '',
|
|
};
|
|
}
|
|
case 'DIALOGUES_MESSAGE_PUSH': {
|
|
const { type, data } = action.payload;
|
|
const id = data._id;
|
|
if (type === 'new') {
|
|
return {
|
|
...state,
|
|
[id]: '',
|
|
};
|
|
}
|
|
return state;
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
}
|