mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where the connection wasn't being closed when the user switched
to a new connection and closed the query tool. Fixes #7461 Fixed the 'Show activity?' issue which was missed during Dashboard porting.
This commit is contained in:
committed by
Akshay Joshi
parent
2556771c32
commit
e95eb14651
@@ -346,6 +346,15 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
}, []);
|
||||
|
||||
useEffect(()=>{
|
||||
const closeConn = ()=>{
|
||||
api.delete(
|
||||
url_for('sqleditor.close', {
|
||||
'trans_id': qtState.params.trans_id,
|
||||
})
|
||||
);
|
||||
};
|
||||
window.addEventListener('unload', closeConn);
|
||||
|
||||
const pushHistory = (h)=>{
|
||||
api.post(
|
||||
url_for('sqleditor.add_query_history', {
|
||||
@@ -355,7 +364,10 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
||||
).catch((error)=>{console.error(error);});
|
||||
};
|
||||
eventBus.current.registerListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory);
|
||||
return ()=>{eventBus.current.deregisterListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory);};
|
||||
return ()=>{
|
||||
eventBus.current.deregisterListener(QUERY_TOOL_EVENTS.PUSH_HISTORY, pushHistory);
|
||||
window.removeEventListener('unload', closeConn);
|
||||
};
|
||||
}, [qtState.params.trans_id]);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user