fix for pagination. just show what ever data received from api without checking unique
This commit is contained in:
parent
a9c0315697
commit
6fd7a6531b
|
|
@ -68,10 +68,12 @@ export const peopleSlice = createSlice({
|
|||
},
|
||||
loadPrefetched: (state, action) => {
|
||||
if(state.prefetched.length > 0){
|
||||
const records = new Set([...state.people, ...state.prefetched]);
|
||||
const unique = [];
|
||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
state.people = unique
|
||||
//const records = new Set([...state.people, ...state.prefetched]);
|
||||
const records = [...state.people, ...state.prefetched];
|
||||
//const unique = [];
|
||||
//records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
//state.people = unique
|
||||
state.people = records;
|
||||
}
|
||||
state.prefetched = []
|
||||
}
|
||||
|
|
@ -82,13 +84,16 @@ export const peopleSlice = createSlice({
|
|||
state.status = 'loading'
|
||||
})
|
||||
.addCase(fetchPeople.fulfilled, (state, action) => {
|
||||
const records = new Set([...state.people, ...action.payload.musicians]);
|
||||
const unique = [];
|
||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
state.people = unique
|
||||
//const records = new Set([...state.people, ...action.payload.musicians]);
|
||||
const records = [...state.people, ...action.payload.musicians];
|
||||
//const unique = [];
|
||||
//records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
//state.people = unique
|
||||
state.people = records
|
||||
//state.totalPages = action.payload.page_count
|
||||
state.hasOffset = !!action.payload.offset
|
||||
state.status = 'succeeded'
|
||||
console.log('******fetchPeople.fulfilled -> state.people', state.people);
|
||||
})
|
||||
.addCase(fetchPeople.rejected, (state, action) => {
|
||||
state.status = 'failed'
|
||||
|
|
@ -97,12 +102,15 @@ export const peopleSlice = createSlice({
|
|||
.addCase(preFetchPeople.pending, (state, action) => {
|
||||
})
|
||||
.addCase(preFetchPeople.fulfilled, (state, action) => {
|
||||
const records = new Set([...state.prefetched, ...action.payload.musicians]);
|
||||
const unique = [];
|
||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
state.prefetched = unique
|
||||
//const records = new Set([...state.prefetched, ...action.payload.musicians]);
|
||||
const records = [...state.prefetched, ...action.payload.musicians];
|
||||
//const unique = [];
|
||||
//records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
||||
//state.prefetched = unique
|
||||
state.prefetched = records
|
||||
//state.totalPages = action.payload.page_count
|
||||
state.hasOffset = !!action.payload.offset
|
||||
console.log('******preFetchPeople.fulfilled -> state.prefetched', state.prefetched);
|
||||
})
|
||||
.addCase(preFetchPeople.rejected, (state, action) => {
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue