generated from nhcarrigan/template
fix: sort injected entries by canonical defaults order after sync
This commit is contained in:
@@ -533,6 +533,13 @@ const injectMissingEntries = <T extends { id: string }>(
|
||||
added = added + 1;
|
||||
}
|
||||
}
|
||||
const defaultOrder = new Map(defaults.map((item, index) => {
|
||||
return [ item.id, index ] as const;
|
||||
}));
|
||||
existing.sort((itemA, itemB) => {
|
||||
return (defaultOrder.get(itemA.id) ?? Number.MAX_SAFE_INTEGER)
|
||||
- (defaultOrder.get(itemB.id) ?? Number.MAX_SAFE_INTEGER);
|
||||
});
|
||||
return added;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user