Skip to content

Commit

Permalink
Fix deep equality logic (apache#4730)
Browse files Browse the repository at this point in the history
* Fix deepequality logic

Zeroed-in on this while a Deck Scatter Plot chart was prompting for
refresh on-load.

I'm pretty sure using JSON.stringify as a proxy for deep equality is
wrong.

Not sure how to handle yarn.lock changes here. The changes on yarn.lock
are the result of "only" running `yarn add deep-equal`

* Adressing comments
  • Loading branch information
mistercrunch authored and michellethomas committed May 23, 2018
1 parent 12834ec commit 194e8ea
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 194 deletions.
3 changes: 2 additions & 1 deletion superset/assets/javascripts/reduxUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shortid from 'shortid';
import { compose } from 'redux';
import persistState from 'redux-localstorage';
import equals from 'deep-equal';

export function addToObject(state, arrKey, obj) {
const newObject = Object.assign({}, state[arrKey]);
Expand Down Expand Up @@ -95,5 +96,5 @@ export function areArraysShallowEqual(arr1, arr2) {
}

export function areObjectsEqual(obj1, obj2) {
return JSON.stringify(obj1) === JSON.stringify(obj2);
return equals(obj1, obj2, true);
}
1 change: 1 addition & 0 deletions superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"datamaps": "^0.5.8",
"datatables.net-bs": "^1.10.15",
"deck.gl": "^5.0.1",
"deep-equal": "^1.0.1",
"distributions": "^1.0.0",
"dompurify": "^1.0.3",
"fastdom": "^1.0.6",
Expand Down
Loading

0 comments on commit 194e8ea

Please sign in to comment.