mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
fix: order when loading more than 10 relations (#21855)
* fix: relations page loading * chore: comment * fix: do not regenerate all keys
This commit is contained in:
parent
df298029ec
commit
3db8f1fc61
@ -66,9 +66,13 @@ const relationsApi = contentManagerApi.injectEndpoints({
|
||||
/**
|
||||
* Relations will always have unique IDs, so we can therefore assume
|
||||
* that we only need to push the new items to the cache.
|
||||
*
|
||||
* Push new items at the beginning as latest items are shown first
|
||||
*/
|
||||
|
||||
currentCache.results.push(...prepareTempKeys(newItems.results, currentCache.results));
|
||||
currentCache.results = [
|
||||
...prepareTempKeys(newItems.results, currentCache.results),
|
||||
...currentCache.results,
|
||||
];
|
||||
currentCache.pagination = newItems.pagination;
|
||||
} else if (newItems.pagination.page === 1) {
|
||||
/**
|
||||
@ -180,7 +184,6 @@ const relationsApi = contentManagerApi.injectEndpoints({
|
||||
*/
|
||||
const prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {
|
||||
const [firstItem] = existingRelations.slice(0);
|
||||
|
||||
const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);
|
||||
|
||||
return relations.map((datum, index) => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user