mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-20 22:10:30 +00:00
Merge pull request #3134 from weaveworks/use-json-stable-stringify
Don't update route if it hasn't changed
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import page from 'page';
|
||||
import stableStringify from 'json-stable-stringify';
|
||||
import { fromJS, is as isDeepEqual } from 'immutable';
|
||||
import { each, omit, omitBy, isEmpty } from 'lodash';
|
||||
|
||||
@@ -107,9 +108,12 @@ export function getUrlState(state) {
|
||||
|
||||
export function updateRoute(getState) {
|
||||
const state = getUrlState(getState());
|
||||
const stateUrl = encodeURL(JSON.stringify(state));
|
||||
const dispatch = false;
|
||||
const prevState = parseHashState();
|
||||
const dispatch = false;
|
||||
|
||||
const stateUrl = encodeURL(stableStringify(state));
|
||||
const prevStateUrl = encodeURL(stableStringify(prevState));
|
||||
if (stateUrl === prevStateUrl) return;
|
||||
|
||||
// back up state in storage as well
|
||||
storageSet(STORAGE_STATE_KEY, stateUrl);
|
||||
@@ -152,7 +156,7 @@ export function getRouter(dispatch, initialState) {
|
||||
} else {
|
||||
const mergedState = Object.assign(initialState, parsedState);
|
||||
// push storage state to URL
|
||||
window.location.hash = `!/state/${JSON.stringify(mergedState)}`;
|
||||
window.location.hash = `!/state/${stableStringify(mergedState)}`;
|
||||
dispatch(route(mergedState));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"filter-invalid-dom-props": "2.0.0",
|
||||
"font-awesome": "4.7.0",
|
||||
"immutable": "3.8.2",
|
||||
"json-stable-stringify": "1.0.1",
|
||||
"lcp": "1.1.0",
|
||||
"lodash": "4.17.4",
|
||||
"materialize-css": "0.98.1",
|
||||
|
||||
Reference in New Issue
Block a user