diff --git a/frontend/src/lib/storage-manager/storage-manager.js b/frontend/src/lib/storage-manager/storage-manager.js index 418d92224..c44c8710f 100644 --- a/frontend/src/lib/storage-manager/storage-manager.js +++ b/frontend/src/lib/storage-manager/storage-manager.js @@ -327,6 +327,7 @@ export class StorageManager { const url = (options.history && options.history.url) || (this._global.document && this._global.document.location); const state = this._global.history.state || {}; + //alert('Current State of history: ' + JSON.stringify(state)); state[this.namespace] = this._updateStorage({}, value, LOCATION.HISTORY, options); this._debugLog('_saveToHistory', { state: state, push: push, title: title, url: url}); @@ -359,6 +360,12 @@ export class StorageManager { addHistoryListener(listener, options=this._options, ...args) { const modified_listener = (function(event, ...listener_args) { // eslint-disable-line no-unused-vars + alert('Event:' + JSON.stringify(event)); + + //possible solution: popstate event does not have a state + if(event.state === null) + return; + this._global.setTimeout(() => listener(this._getFromHistory(options), ...listener_args)); }).bind(this); @@ -472,10 +479,10 @@ export class StorageManager { }).catch(console.error); } - _debugLog() {} - // _debugLog(fName, ...args) { - // console.log(`[DEBUGLOG] StorageManager.${fName}`, { args: args, instance: this }); - // } + //_debugLog() {} + _debugLog(fName, ...args) { + console.log(`[DEBUGLOG] StorageManager.${fName}`, { args: args, instance: this }); + } }