Skip to content

Commit 2d8031f

Browse files
author
dmelnik
committed
fix(entityAdapter): fixes after CR
1 parent e3ca55f commit 2d8031f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/toolkit/src/entities/sorted_state_adapter.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
7070
newEntities = ensureEntitiesArray(newEntities)
7171

7272
const existingKeys = new Set<Id>(existingIds ?? getCurrent(state.ids))
73-
const addedKeys = new Set<Id>([]);
73+
const addedKeys = new Set<Id>();
7474
const models = newEntities.filter(
7575
(model) => {
76-
const modelId = selectIdValue(model, selectId);
77-
return !existingKeys.has(modelId) && !addedKeys.has(modelId) && addedKeys.add(modelId);
78-
},
76+
const modelId = selectIdValue(model, selectId);
77+
const notAdded = !addedKeys.has(modelId);
78+
if (notAdded) addedKeys.add(modelId);
79+
return !existingKeys.has(modelId) && notAdded;
80+
}
7981
)
8082

8183
if (models.length !== 0) {

0 commit comments

Comments
 (0)