From a9ae7ca0991b34e1e6fa0bdf2d2b4ccb86fdd9e4 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Mon, 19 Jun 2023 16:28:48 +0530 Subject: [PATCH] Ensure that query tool status poller is paused if the query tool is not visible/active --- docs/en_US/release_notes_7_4.rst | 10 +++++----- .../js/components/QueryToolComponent.jsx | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/en_US/release_notes_7_4.rst b/docs/en_US/release_notes_7_4.rst index d3fced863..cbdbe9fee 100644 --- a/docs/en_US/release_notes_7_4.rst +++ b/docs/en_US/release_notes_7_4.rst @@ -32,10 +32,10 @@ Bug fixes ********* | `Issue #6065 `_ - Ensure that query tool shortcuts are working properly. - | `Issue #6258 `_ - Password Exec properties not included in import/export servers. - | `Issue #6266 `_ - The object browser (the tree control tab) disappeared. - | `Issue #6291 `_ - If connection is lost but data need to be loaded on demand, then loading indicator will not disappear. - | `Issue #6340 `_ - Unable to connect through Pgbouncer after upgrading from 6.21 to 7.1 + | `Issue #6258 `_ - Add Password exec command and Expiration time to server export JSON and also allow them to import. + | `Issue #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 `_ - Fix an issue where loading more rows indicator will not disappear if connection is lost. + | `Issue #6340 `_ - Fix an encoding error when connecting through Pgbouncer. | `Issue #6363 `_ - Fixed an issue where preview images for themes were not loading. - | `Issue #6431 `_ - PSQL not working if the database name have quotes and double quotes. + | `Issue #6431 `_ - Fix an issue where PSQL is not working if the database name have quotes or double quotes. diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index 26a8e8c18..cc4fe97f5 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -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}); } }); }, []);