Skip to content

Commit

Permalink
Collections now preserving order when joined with external config
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Dec 13, 2024
1 parent 54709b0 commit 7a22bd0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/collection_editor/src/utils/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const mergeCollections = (baseCollections: EntityCollection[],
console.debug("Collections specified in code:", baseCollections);
console.debug("Collections stored in the backend", storedCollections);
const result = joinCollectionLists(baseCollections, storedCollections, [], modifyCollection);

// sort the collections so they are in the same order as the base collections
result.sort((a, b) => baseCollections.findIndex(c => c.id === a.id) - baseCollections.findIndex(c => c.id === b.id));

console.debug("Collections after joining:", result);
return result;
}

0 comments on commit 7a22bd0

Please sign in to comment.