Created
March 31, 2016 07:57
-
-
Save itsmepetrov/c62da42f7b7d5ed8100385aa2028dcc9 to your computer and use it in GitHub Desktop.
redux-entities relation issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineEntitiesReducers } from 'redux-entities'; | |
import messages from './messages'; | |
import tickets from './tickets'; | |
export default combineEntitiesReducers({ | |
messages, | |
tickets | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = {}; | |
export default function messages(state = initialState) { | |
return state; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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