mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[state_management] if a state should be persisted, force it back into the url
This commit is contained in:
parent
04a2227076
commit
4c8a49bc64
1 changed files with 13 additions and 3 deletions
|
@ -39,7 +39,7 @@ define(function (require) {
|
|||
|
||||
State.prototype._readFromURL = function () {
|
||||
var search = $location.search();
|
||||
return rison.decode(search[this._urlParam] || '()');
|
||||
return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,17 @@ define(function (require) {
|
|||
* @returns {void}
|
||||
*/
|
||||
State.prototype.fetch = function () {
|
||||
var stash = this._readFromURL('fetch');
|
||||
var stash = this._readFromURL();
|
||||
|
||||
// nothing to read from the url?
|
||||
// we should save if were are ordered to persist
|
||||
if (stash === null) {
|
||||
if (this._persistAcrossApps) {
|
||||
return this.save();
|
||||
} else {
|
||||
stash = {};
|
||||
}
|
||||
}
|
||||
|
||||
_.defaults(stash, this._defaults);
|
||||
// apply diff to state from stash, will change state in place via side effect
|
||||
|
@ -63,7 +73,7 @@ define(function (require) {
|
|||
* @returns {void}
|
||||
*/
|
||||
State.prototype.save = function () {
|
||||
var stash = this._readFromURL('save');
|
||||
var stash = this._readFromURL() || {};
|
||||
var state = this.toObject();
|
||||
|
||||
_.defaults(state, this._defaults);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue