Only check for new version when idle

This commit is contained in:
Eduard Urbach 2018-04-09 01:21:50 +02:00
parent c0fb2f2c72
commit c0594d0888

View File

@ -1,4 +1,4 @@
import { delay } from "./Utils" import { delay, requestIdleCallback } from "./Utils"
import StatusMessage from "./StatusMessage" import StatusMessage from "./StatusMessage"
let etags = new Map<string, string>() let etags = new Map<string, string>()
@ -52,6 +52,8 @@ async function checkNewVersion(url: string, statusMessage: StatusMessage) {
} }
} }
export async function checkNewVersionDelayed(url: string, statusMessage: StatusMessage) { export function checkNewVersionDelayed(url: string, statusMessage: StatusMessage) {
delay(newVersionCheckDelay).then(() => checkNewVersion(url, statusMessage)) return delay(newVersionCheckDelay).then(() => {
requestIdleCallback(() => checkNewVersion(url, statusMessage))
})
} }