Skip to content

Commit

Permalink
Do not use hashCode anymore, replace by equals instead
Browse files Browse the repository at this point in the history
See immutable-js/immutable-js#1894
about hashCode collisions and booleans.
  • Loading branch information
Skywalker13 committed Oct 27, 2022
1 parent 3ff3db4 commit c0c42be
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/index.js
Expand Up @@ -973,15 +973,12 @@ class Goblin {
//remove private state from upserted data
payload.data = payload.data.delete('private');

const hash = payload.data.hashCode();
if (!this.lastUpsertHash) {
this.lastUpsertHash = hash;
if (!this.lastUpsertData) {
this.lastUpsertData = payload.data;
yield quest.warehouse.upsert(payload);
} else {
if (this.lastUpsertHash !== hash) {
yield quest.warehouse.upsert(payload);
this.lastUpsertHash = hash;
}
} else if (!this.lastUpsertData.equals(payload)) {
yield quest.warehouse.upsert(payload);
this.lastUpsertData = payload.data;
}
}

Expand Down

0 comments on commit c0c42be

Please sign in to comment.