Disable Button during time interval between queries


Skärmavbild 2020-01-26 kl. 22.16.11.png

I want to disable a button during the set delay between some of my queries (see screenshot). I know how to disable the button while the query is running (or rather "isFetching"). Does anyone of you have any idea's on how I can solve this?

So… This should be pretty straightforward but it gets a little strange because component properties only recalculate when a query value inside of the JS changes. moment() creates a moment object for the current time, but it doesn’t recalculate every millisecond. moment().isBefore(moment(query3.timestamp+query3.queryTriggerDelay)) will nicely return true/false if we are currently within the trigger delay timeframe.

However, because none of those values in that tag change at any point AFTER query3 gets triggered, we need to somehow reference one of the queries that get triggered after the delay, since those WILL update after the delay

Which leads me to this monstrosity:

{{query1 ? moment().isBefore(moment(query3.timestamp+query3.queryTriggerDelay)) : moment().isBefore(moment(query3.timestamp+query3.queryTriggerDelay)) }}

If query1 (the one triggered by query3) anything, not specified, doesn’t actually matter what it is just that it references the query, THEN return the true/false statement if query1 is true or false

I’m not happy with it, there is probably a better JS format to successfully reference the triggered query in some form to get access to the listener, however this does work nicely. Does that help @daniel-andersson?

Thanks Alex! I haven’t got the time to test it yet. I’ll post the results here later.

Is it possible to disable a button after running the query ?

On clicking the button, a query runs and later on the button must be disabled

Hey @tester-

two potential options on that which come to mind for me. The first is that before a query runs, it's .data property will be null. If running the query returns some value, you could use that as a condition to check whether it has run yet to disable the button (i.e. {{!!query.data}} to disable the button).

You could also use the query's .finished property, which is a timestamp of when the query last finished running if you want to be more precise or there are more scenarios to account for, i.e. the query re-running