prevent duplicate entries in friends page
This commit is contained in:
parent
edb6bd0b90
commit
bd45275107
|
|
@ -80,8 +80,16 @@ export const peopleSlice = createSlice({
|
|||
state.status = 'loading'
|
||||
})
|
||||
.addCase(fetchPeople.fulfilled, (state, action) => {
|
||||
const records = [...state.people, ...action.payload.musicians];
|
||||
state.people = records
|
||||
// const records = [...state.people, ...action.payload.musicians];
|
||||
// state.people = records
|
||||
// state.hasOffset = !!action.payload.offset
|
||||
// state.offset = action.payload.offset
|
||||
// state.status = 'succeeded'
|
||||
//---
|
||||
const records = new Set([...state.people, ...action.payload.musicians]);
|
||||
const unique = [];
|
||||
records.map(x => unique.filter(p => p.id === x.id).length > 0 ? null : unique.push(x))
|
||||
state.people = unique
|
||||
state.hasOffset = !!action.payload.offset
|
||||
state.offset = action.payload.offset
|
||||
state.status = 'succeeded'
|
||||
|
|
@ -94,8 +102,16 @@ export const peopleSlice = createSlice({
|
|||
state.status = 'loading'
|
||||
})
|
||||
.addCase(preFetchPeople.fulfilled, (state, action) => {
|
||||
const records = [...state.prefetched, ...action.payload.musicians];
|
||||
state.prefetched = records
|
||||
// const records = [...state.prefetched, ...action.payload.musicians];
|
||||
// state.prefetched = records
|
||||
// state.hasOffset = !!action.payload.offset
|
||||
// state.offset = action.payload.offset
|
||||
// state.status = 'succeeded'
|
||||
//---
|
||||
const records = new Set([...state.prefetched, ...action.payload.musicians]);
|
||||
const unique = [];
|
||||
records.map(x => unique.filter(p => p.id === x.id).length > 0 ? null : unique.push(x))
|
||||
state.people = unique
|
||||
state.hasOffset = !!action.payload.offset
|
||||
state.offset = action.payload.offset
|
||||
state.status = 'succeeded'
|
||||
|
|
|
|||
Loading…
Reference in New Issue