Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idle API: no way to reset the interval to default after idle.setDetectionInterval() #452

Open
NV opened this issue Sep 14, 2023 · 0 comments
Labels
discussion Needs further discussion enhancement Enhancement or change to an existing feature proposal Proposal for a change or new feature

Comments

@NV
Copy link

NV commented Sep 14, 2023

TL;DR: the default interval is not exposed so to revert it back to the initial value you have to hardcode the number from the documentation.

setDetectionInterval

chrome.idle.setDetectionInterval(
  intervalInSeconds: number,
)

Sets the interval, in seconds, used to determine when the system is in an idle state for onStateChanged events. The default interval is 60 seconds.

from: https://developer.chrome.com/docs/extensions/reference/idle/#method-setDetectionInterval (similar page on mdn)

Once you set the interval, it persists. There's no way to revert to the default interval. There's no way to read the current interval.

It would be nice to expose the default value, like so:

browser.idle.DEFAULT_INTERVAL_IN_SECONDS = 60

Similarly, there's no mention of the interval's minimum.

await chrome.idle.queryState(10) throws (at least in Chrome)

Uncaught TypeError: Error in invocation of idle.queryState(integer detectionIntervalInSeconds, function callback):
Error at parameter 'detectionIntervalInSeconds': Value must be at least 15.

It would be nice to expose:

browser.idle.MINIMUM_INTERVAL_IN_SECONDS = 15

Currently, I have to program defensively and wrap each setDetectionInterval and queryState call into try/catch, in case the minimum interval constant changes.

@NV NV added enhancement Enhancement or change to an existing feature discussion Needs further discussion labels Sep 14, 2023
@NV NV changed the title idle API: no way to reset to default interval after idle.setDetectionInterval() idle API: no way to reset the interval to default after idle.setDetectionInterval() Sep 14, 2023
@NV NV added the proposal Proposal for a change or new feature label Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs further discussion enhancement Enhancement or change to an existing feature proposal Proposal for a change or new feature
Projects
None yet
Development

No branches or pull requests

1 participant