Merge pull request #220 from toasted-nutbread/zero-scanning-delay-timeout

Use a Promise to trigger callback when delay is 0 or less
This commit is contained in:
Alex Yatskov 2019-09-22 10:05:53 -07:00 committed by GitHub
commit 64eec04a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,7 +269,12 @@ class Frontend {
} }
popupTimerSet(callback) { popupTimerSet(callback) {
this.popupTimer = window.setTimeout(callback, this.options.scanning.delay); const delay = this.options.scanning.delay;
if (delay > 0) {
this.popupTimer = window.setTimeout(callback, delay);
} else {
Promise.resolve().then(callback);
}
} }
popupTimerClear() { popupTimerClear() {