Ensure that query tool status poller is paused if the query tool is not visible/active

This commit is contained in:
Aditya Toshniwal 2023-06-19 16:28:48 +05:30
parent d21e1eb17e
commit a9ae7ca099
2 changed files with 21 additions and 7 deletions

View File

@ -32,10 +32,10 @@ Bug fixes
*********
| `Issue #6065 <https://github.com/pgadmin-org/pgadmin4/issues/6065>`_ - Ensure that query tool shortcuts are working properly.
| `Issue #6258 <https://github.com/pgadmin-org/pgadmin4/issues/6258>`_ - Password Exec properties not included in import/export servers.
| `Issue #6266 <https://github.com/pgadmin-org/pgadmin4/issues/6266>`_ - The object browser (the tree control tab) disappeared.
| `Issue #6291 <https://github.com/pgadmin-org/pgadmin4/issues/6291>`_ - If connection is lost but data need to be loaded on demand, then loading indicator will not disappear.
| `Issue #6340 <https://github.com/pgadmin-org/pgadmin4/issues/6340>`_ - Unable to connect through Pgbouncer after upgrading from 6.21 to 7.1
| `Issue #6258 <https://github.com/pgadmin-org/pgadmin4/issues/6258>`_ - Add Password exec command and Expiration time to server export JSON and also allow them to import.
| `Issue #6266 <https://github.com/pgadmin-org/pgadmin4/issues/6266>`_ - When opening pgAdmin the layout should be auto reset if it is corrupted. Reset layout menu should work if layout is corrupted while using pgAdmin.
| `Issue #6291 <https://github.com/pgadmin-org/pgadmin4/issues/6291>`_ - Fix an issue where loading more rows indicator will not disappear if connection is lost.
| `Issue #6340 <https://github.com/pgadmin-org/pgadmin4/issues/6340>`_ - Fix an encoding error when connecting through Pgbouncer.
| `Issue #6363 <https://github.com/pgadmin-org/pgadmin4/issues/6363>`_ - Fixed an issue where preview images for themes were not loading.
| `Issue #6431 <https://github.com/pgadmin-org/pgadmin4/issues/6431>`_ - PSQL not working if the database name have quotes and double quotes.
| `Issue #6431 <https://github.com/pgadmin-org/pgadmin4/issues/6431>`_ - Fix an issue where PSQL is not working if the database name have quotes or double quotes.

View File

@ -86,6 +86,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
browser: {}, sqleditor: {}, graphs: {}, misc: {},
},
is_new_tab: window.location == window.parent?.location,
is_visible: true,
current_file: null,
obtaining_conn: true,
connected: false,
@ -128,8 +129,9 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
let pollTime = qtState.preferences.sqleditor.connection_status_fetch_time > 0
&& !qtState.obtaining_conn && qtState.connected_once && qtState.preferences?.sqleditor?.connection_status ?
qtState.preferences.sqleditor.connection_status_fetch_time*1000 : -1;
/* No need to poll when the query is executing. Query poller will the txn status */
if(qtState.connection_status === CONNECTION_STATUS.TRANSACTION_STATUS_ACTIVE && qtState.connected) {
/* No need to poll when the query is executing. Query poller will get the txn status */
if(qtState.connection_status === CONNECTION_STATUS.TRANSACTION_STATUS_ACTIVE && qtState.connected
|| !qtState.is_visible) {
pollTime = -1;
}
useInterval(async ()=>{
@ -346,6 +348,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
panel?.on(window.wcDocker.EVENT.VISIBILITY_CHANGED, function() {
/* Focus the appropriate panel on visible */
if(panel.isVisible()) {
setQtState({is_visible: true});
if(LayoutHelper.isTabVisible(docker.current, PANELS.QUERY)) {
LayoutHelper.focus(docker.current, PANELS.QUERY);
} else if(LayoutHelper.isTabVisible(docker.current, PANELS.HISTORY)) {
@ -353,6 +356,17 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
}
eventBus.current.fireEvent(QUERY_TOOL_EVENTS.GOTO_LAST_SCROLL);
} else {
setQtState({is_visible: false});
}
});
/* If the tab or window is not visible */
document.addEventListener('visibilitychange', function() {
if(document.hidden) {
setQtState({is_visible: false});
} else {
setQtState({is_visible: true});
}
});
}, []);