From 3322956970163d3310fb7d2ad6d0e2e22f2e2c3e Mon Sep 17 00:00:00 2001 From: Ethan Hathaway Date: Thu, 12 Mar 2020 13:16:03 -0700 Subject: [PATCH] Fix: rehydrate flag --- package.json | 2 +- src/history.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fa12abe..c7b2151 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@social-native/snpkg-client-elasticsearch", - "version": "3.6.0", + "version": "3.6.1", "description": "", "main": "dist/index.cjs.js", "module": "dist/index.es.js", diff --git a/src/history.ts b/src/history.ts index 78015a5..218bb19 100644 --- a/src/history.ts +++ b/src/history.ts @@ -143,27 +143,37 @@ class History { * Rehydrates state from current state store (URL) or persistent storage (localStorage) */ public rehydrate = () => { + // tslint:disable-next-line runInAction(() => { if (this.historyPersister) { const persistedHistory = this.historyPersister.getHistory(); this.history = persistedHistory; if (persistedHistory.length > 0) { - this.hasRehydratedLocation = true; const existingStateFromUrl = this.currentLocationStore.getState(); if (!existingStateFromUrl) { const newHistoryLocation = this._deepCopy( persistedHistory[0] as HistoryLocation ); + // if only suggestions are present then we should + // act as if no location was rehydrated + if (newHistoryLocation.filters) { + this.hasRehydratedLocation = true; + } this.currentLocationStore.setState(newHistoryLocation); this._rehydrateFromLocation(newHistoryLocation); } else { + if (existingStateFromUrl.filters) { + this.hasRehydratedLocation = true; + } this._rehydrateFromLocation(existingStateFromUrl); } } else { const existingStateFromUrl = this.currentLocationStore.getState(); if (existingStateFromUrl) { - this.hasRehydratedLocation = true; + if (existingStateFromUrl.filters) { + this.hasRehydratedLocation = true; + } this._rehydrateFromLocation(existingStateFromUrl); } }