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) => {
|
loadPrefetched: (state, action) => {
|
||||||
if(state.prefetched.length > 0){
|
if(state.prefetched.length > 0){
|
||||||
const records = new Set([...state.people, ...state.prefetched]);
|
//const records = new Set([...state.people, ...state.prefetched]);
|
||||||
const unique = [];
|
const records = [...state.people, ...state.prefetched];
|
||||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
//const unique = [];
|
||||||
state.people = 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 = []
|
state.prefetched = []
|
||||||
}
|
}
|
||||||
|
|
@ -82,13 +84,16 @@ export const peopleSlice = createSlice({
|
||||||
state.status = 'loading'
|
state.status = 'loading'
|
||||||
})
|
})
|
||||||
.addCase(fetchPeople.fulfilled, (state, action) => {
|
.addCase(fetchPeople.fulfilled, (state, action) => {
|
||||||
const records = new Set([...state.people, ...action.payload.musicians]);
|
//const records = new Set([...state.people, ...action.payload.musicians]);
|
||||||
const unique = [];
|
const records = [...state.people, ...action.payload.musicians];
|
||||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
//const unique = [];
|
||||||
state.people = 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.totalPages = action.payload.page_count
|
||||||
state.hasOffset = !!action.payload.offset
|
state.hasOffset = !!action.payload.offset
|
||||||
state.status = 'succeeded'
|
state.status = 'succeeded'
|
||||||
|
console.log('******fetchPeople.fulfilled -> state.people', state.people);
|
||||||
})
|
})
|
||||||
.addCase(fetchPeople.rejected, (state, action) => {
|
.addCase(fetchPeople.rejected, (state, action) => {
|
||||||
state.status = 'failed'
|
state.status = 'failed'
|
||||||
|
|
@ -97,12 +102,15 @@ export const peopleSlice = createSlice({
|
||||||
.addCase(preFetchPeople.pending, (state, action) => {
|
.addCase(preFetchPeople.pending, (state, action) => {
|
||||||
})
|
})
|
||||||
.addCase(preFetchPeople.fulfilled, (state, action) => {
|
.addCase(preFetchPeople.fulfilled, (state, action) => {
|
||||||
const records = new Set([...state.prefetched, ...action.payload.musicians]);
|
//const records = new Set([...state.prefetched, ...action.payload.musicians]);
|
||||||
const unique = [];
|
const records = [...state.prefetched, ...action.payload.musicians];
|
||||||
records.map(x => unique.filter(a => a.id === x.id).length > 0 ? null : unique.push(x))
|
//const unique = [];
|
||||||
state.prefetched = 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.totalPages = action.payload.page_count
|
||||||
state.hasOffset = !!action.payload.offset
|
state.hasOffset = !!action.payload.offset
|
||||||
|
console.log('******preFetchPeople.fulfilled -> state.prefetched', state.prefetched);
|
||||||
})
|
})
|
||||||
.addCase(preFetchPeople.rejected, (state, action) => {
|
.addCase(preFetchPeople.rejected, (state, action) => {
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue