Skip to content

Commit

Permalink
Fix for unsupported includes() in unsorted_state_adapter
Browse files Browse the repository at this point in the history
CircleCI failed the build because includes() is not supported
by its runtime yet. We use an alternative syntax to fix that.
  • Loading branch information
Denis Loginov committed Sep 29, 2017
1 parent 8dcb54c commit 8efba70
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions modules/entity/src/unsorted_state_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ export function createUnsortedStateAdapter<T>(
keys: { [id: string]: string },
update: Update<T>,
state: R
): boolean {
if (!(update.id in state.entities)) {
return false;
}

): void {
const original = state.entities[update.id];
const updated: T = Object.assign({}, original, update.changes);
const newKey = selectId(updated);
Expand All @@ -81,8 +77,6 @@ export function createUnsortedStateAdapter<T>(
}

state.entities[newKey] = updated;

return true;
}

function updateOneMutably(update: Update<T>, state: R): boolean {
Expand All @@ -92,9 +86,10 @@ export function createUnsortedStateAdapter<T>(
function updateManyMutably(updates: Update<T>[], state: R): boolean {
const newKeys: { [id: string]: string } = {};

const didMutate = updates
.map(update => takeNewKey(newKeys, update, state))
.includes(true);
const didMutate =
updates
.filter(update => update.id in state.entities)
.map(update => takeNewKey(newKeys, update, state)).length > 0;

if (didMutate) {
state.ids = state.ids.map(id => newKeys[id] || id);
Expand Down

0 comments on commit 8efba70

Please sign in to comment.