mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
replacing message if modifying it
This commit is contained in:
parent
a06e54bd78
commit
5e85ae2aee
1 changed files with 17 additions and 6 deletions
|
@ -82,12 +82,23 @@ function* sendMessage({ message, onSuccess }: ReturnType<typeof messagesSendMess
|
||||||
|
|
||||||
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
||||||
|
|
||||||
yield put(
|
if (message.id > 0) {
|
||||||
messagesSet({
|
// modified
|
||||||
is_sending_messages: false,
|
yield put(
|
||||||
messages: [data.message, ...messages],
|
messagesSet({
|
||||||
})
|
is_sending_messages: false,
|
||||||
);
|
messages: messages.map(item => (item.id === message.id ? data.message : item)),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// created
|
||||||
|
yield put(
|
||||||
|
messagesSet({
|
||||||
|
is_sending_messages: false,
|
||||||
|
messages: [data.message, ...messages],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue