Fix for new post ids after entity adapter is added
parent
4c4fe735c1
commit
573491db42
|
@ -99,12 +99,8 @@ const postsSlice = createSlice({
|
||||||
// Creating sortedPosts & assigning the id
|
// Creating sortedPosts & assigning the id
|
||||||
// would be not be needed if the fake API
|
// would be not be needed if the fake API
|
||||||
// returned accurate new post IDs
|
// returned accurate new post IDs
|
||||||
const sortedPosts = state.posts.sort((a, b) => {
|
|
||||||
if (a.id > b.id) return 1
|
action.payload.id = state.ids[state.ids.length - 1] + 1
|
||||||
if (a.id < b.id) return -1
|
|
||||||
return 0
|
|
||||||
})
|
|
||||||
action.payload.id = sortedPosts[sortedPosts.length - 1].id + 1;
|
|
||||||
// End fix for fake API post IDs
|
// End fix for fake API post IDs
|
||||||
|
|
||||||
action.payload.userId = Number(action.payload.userId)
|
action.payload.userId = Number(action.payload.userId)
|
||||||
|
|
Loading…
Reference in New Issue