Hello! What is the most reliable way to disable a periodic query when the document is hidden?
We have tried referencing document.hidden and document.visibilityState in the query's disable field, but these values are not updated when the visibility state changes.
We tried a similar approach using a transformer that returned the current document.visibilityState, but that value is not updated reliably.
Or current "solution" uses a query on page load to set an event listener on the document, that updates some app state for the visibility state, but I have to assume this will be unreliable in the long term.
Can you share more details about your use case so we can determine the best solution or feature request?
For example, components all have a hidden property that will be updated based on whether the component is shown in the app. You can disable periodic queries based on the hidden state of a component:
We have a chart that displays streaming data and has an option to "auto refresh" with the most up to date data. The auto refresh button enables the query to run periodically. We want to ensure that if a user has enabled "auto refresh" but has navigated to another tab on their browser, the query will not continue to run while the tab or browser window is not in view.
The document.hidden or document.visibilityState properties exposed in the global scope of the browser communicate this perfectly, but unfortunately their state does not seem to be updated wherever retool checks to see if a periodic query should be disabled or not.