Skip to content

Instantly share code, notes, and snippets.

@michael-mckenna
Created June 4, 2021 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michael-mckenna/d04e8706c2d04ceba7cfe38c0d6f12c9 to your computer and use it in GitHub Desktop.
Save michael-mckenna/d04e8706c2d04ceba7cfe38c0d6f12c9 to your computer and use it in GitHub Desktop.
case EMessageActions.AddMessage:
const channelId = action.payload[0];
const newMsg = action.payload[1];
const entity = state.entities[channelId];
const newMsgArray = [
...entity.messages,
newMsg
];
// Creates new entity with the new message, or updates an existing entity and appends message
return messageAdapter.upsertOne({
...entity,
messages: newMsgArray
}, state);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment