Fixed an issue where browser tree state is not remembered when reopening pgAdmin. #5777

pull/6126/head
Pravesh Sharma 2023-04-13 13:02:46 +05:30 committed by GitHub
parent 097080ba97
commit c2a54f3524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 11 deletions

View File

@ -11,7 +11,7 @@ import _ from 'lodash';
import url_for from 'sources/url_for';
import gettext from 'sources/gettext';
import pgAdmin from 'sources/pgadmin';
import getApiInstance from '../api_instance';
import getApiInstance, { callFetch } from '../api_instance';
export const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
@ -86,16 +86,23 @@ _.extend(pgBrowser.browserTreeState, {
if(self.last_state == JSON.stringify(self.current_state))
return;
getApiInstance().post(
url_for('settings.save_tree_state'),
JSON.stringify(self.current_state)
).then(()=> {
self.last_state = JSON.stringify(self.current_state);
self.fetch_state();
}).catch(function(error) {
console.warn(
gettext('Error resetting the tree saved state."'), error);
});
/* Using fetch with keepalive as the browser may
cancel the axios request on tab close. keepalive will
make sure the request is completed */
callFetch(
url_for('settings.save_tree_state'), {
keepalive: true,
method: 'POST',
body: JSON.stringify(self.current_state)
})
.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() {