Trigger the browser tree destroyed event so the consequences of destroying the tree are handled properly.

This commit is contained in:
Khushboo Vashi 2024-04-26 11:59:53 +05:30
parent 2dd009eb7c
commit 2324337149
3 changed files with 8 additions and 5 deletions

View File

@ -555,11 +555,12 @@ export default function PreferencesComponent({ ...props }) {
gettext('Object explorer refresh required'),
gettext('An object explorer refresh is required. Do you wish to refresh it now?'),
function () {
pgAdmin.Browser.tree.destroy({
success: function () {
pgAdmin.Browser.tree.destroy().then(
() => {
pgAdmin.Browser.Events.trigger('pgadmin-browser:tree:destroyed', undefined, undefined);
return true;
},
});
}
);
},
function () {
return true;

View File

@ -42,6 +42,7 @@ export default function withStandardTabInfo(Component, tabId) {
setNodeInfo([true, item, data]);
};
let destroyTree = pgAdmin.Browser.Events.on('pgadmin-browser:tree:destroyed', onUpdate);
let deregisterTree = pgAdmin.Browser.Events.on('pgadmin-browser:node:selected', onUpdate);
let deregisterTreeUpdate = pgAdmin.Browser.Events.on('pgadmin-browser:tree:updated', onUpdate);
let deregisterDbConnected = pgAdmin.Browser.Events.on('pgadmin:database:connected', onUpdate);
@ -54,6 +55,7 @@ export default function withStandardTabInfo(Component, tabId) {
return ()=>{
onTabActive?.cancel();
destroyTree();
deregisterTree();
deregisterTreeUpdate();
deregisterDbConnected();

View File

@ -120,7 +120,7 @@ export class Tree {
this.rootNode.children = [];
if (model.root) {
model.root.isExpanded = false;
await model.root.hardReloadChildren();
return Promise.resolve(await model.root.hardReloadChildren());
}
}