messagepad (react is great!)

This commit is contained in:
undefined committed 2020-06-26 15:51:42 +08:00
1 parent 39ea30664d
commit 560e920624
13 files changed
+146 -279

No files matched your search

+6 -14
View File
@@ -7,10 +7,10 @@ export default function reducer(state = {}, action) {
return _.fromPairs(_.map(dialogues, (d) => [d._id, '']));
}
case 'DIALOGUES_CREATE': {
const { id } = action.payload;
const { user } = action.payload;
return {
...state,
[id]: '',
[user._id]: '',
};
}
case 'DIALOGUES_INPUT_CHANGED': {
@@ -20,27 +20,19 @@ export default function reducer(state = {}, action) {
[id]: action.payload,
};
}
case 'DIALOGUES_POST_REPLY_FULFILLED': {
case 'DIALOGUES_POST_SEND_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') {
const { udoc } = action.payload;
if (!state[udoc._id]) {
return {
...state,
[id]: '',
[udoc._id]: '',
};
}
return state;