Skip to content

Instantly share code, notes, and snippets.

@itsmepetrov
Created March 31, 2016 07:57
Show Gist options
  • Save itsmepetrov/c62da42f7b7d5ed8100385aa2028dcc9 to your computer and use it in GitHub Desktop.
Save itsmepetrov/c62da42f7b7d5ed8100385aa2028dcc9 to your computer and use it in GitHub Desktop.
redux-entities relation issue
import { combineEntitiesReducers } from 'redux-entities';
import messages from './messages';
import tickets from './tickets';
export default combineEntitiesReducers({
messages,
tickets
});
const initialState = {};
export default function messages(state = initialState) {
return state;
}
import {
NEW_MESSAGE_RECEIVED
} from 'constants';
const initialState = {};
export default function tickets(state = initialState, action) {
const { type, payload } = action;
switch (type) {
case NEW_MESSAGE_RECEIVED:
return {
...state
[payload.message.tiketId]: {
...state[payload.message.tiketId],
messages: [
...state[payload.message.tiketId].messages,
payload.message.id
]
}
}
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment