Move message key generation to State.addMessage
This commit is contained in:
parent
c05dcffa7a
commit
d19f127952
2 changed files with 4 additions and 5 deletions
4
state.js
4
state.js
|
@ -136,6 +136,7 @@ function insertMessage(list, msg) {
|
|||
|
||||
let lastServerID = 0;
|
||||
let lastBufferID = 0;
|
||||
let lastMessageKey = 0;
|
||||
|
||||
export const State = {
|
||||
updateServer(state, id, updater) {
|
||||
|
@ -391,6 +392,9 @@ export const State = {
|
|||
}
|
||||
},
|
||||
addMessage(state, msg, bufID) {
|
||||
lastMessageKey++;
|
||||
msg.key = lastMessageKey;
|
||||
|
||||
return State.updateBuffer(state, bufID, (buf) => {
|
||||
let messages = insertMessage(buf.messages, msg);
|
||||
return { messages };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue