Last active
September 26, 2020 21:24
-
-
Save lushiyun/239f65dd925546bc19a1b8715833a5f7 to your computer and use it in GitHub Desktop.
Revisions
-
lushiyun revised this gist
Sep 26, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // src/features/messages/messagesSlice.js ... // omitted imports const messagesAdapter = createEntityAdapter() -
lushiyun revised this gist
Sep 26, 2020 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,10 @@ const messagesAdapter = createEntityAdapter() const initialState = messagesAdapter.getInitialState({ ... }) ... // omitted thunks const messagesSlice = createSlice({ name: 'messages', -
lushiyun revised this gist
Sep 26, 2020 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ ... // omitted imports const messagesAdapter = createEntityAdapter() const initialState = messagesAdapter.getInitialState({ -
lushiyun created this gist
Sep 26, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ ... // omitted imports import { selectTeamById } from '../teams/teamsSlice' const messagesAdapter = createEntityAdapter() const initialState = messagesAdapter.getInitialState({ status: 'idle', error: null, }) ... // omitted thunks for fetching user's messages const messagesSlice = createSlice({ name: 'messages', initialState, reducers: { messageReceived(state, action) { const data = action.payload.data const message = { id: data.id, ...data.attributes, teamId: data.relationships.team.data.id, userId: data.relationships.user.data.id, } messagesAdapter.addOne(state, message) }, }, extraReducers: { ... }, }) export const { messageReceived } = messagesSlice.actions export default messagesSlice.reducer