Fixed an issue where browser tree state is not remembered when reopening pgAdmin. #5777
parent
097080ba97
commit
c2a54f3524
|
@ -11,7 +11,7 @@ import _ from 'lodash';
|
||||||
import url_for from 'sources/url_for';
|
import url_for from 'sources/url_for';
|
||||||
import gettext from 'sources/gettext';
|
import gettext from 'sources/gettext';
|
||||||
import pgAdmin from 'sources/pgadmin';
|
import pgAdmin from 'sources/pgadmin';
|
||||||
import getApiInstance from '../api_instance';
|
import getApiInstance, { callFetch } from '../api_instance';
|
||||||
|
|
||||||
export const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
export const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||||
|
|
||||||
|
@ -86,16 +86,23 @@ _.extend(pgBrowser.browserTreeState, {
|
||||||
if(self.last_state == JSON.stringify(self.current_state))
|
if(self.last_state == JSON.stringify(self.current_state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
getApiInstance().post(
|
/* Using fetch with keepalive as the browser may
|
||||||
url_for('settings.save_tree_state'),
|
cancel the axios request on tab close. keepalive will
|
||||||
JSON.stringify(self.current_state)
|
make sure the request is completed */
|
||||||
).then(()=> {
|
callFetch(
|
||||||
self.last_state = JSON.stringify(self.current_state);
|
url_for('settings.save_tree_state'), {
|
||||||
self.fetch_state();
|
keepalive: true,
|
||||||
}).catch(function(error) {
|
method: 'POST',
|
||||||
console.warn(
|
body: JSON.stringify(self.current_state)
|
||||||
gettext('Error resetting the tree saved state."'), error);
|
})
|
||||||
});
|
.then(()=> {
|
||||||
|
self.last_state = JSON.stringify(self.current_state);
|
||||||
|
self.fetch_state();
|
||||||
|
})
|
||||||
|
.catch((error)=> {
|
||||||
|
console.warn(
|
||||||
|
gettext('Error resetting the tree saved state."'), error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fetch_state: function() {
|
fetch_state: function() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue