fix: run idb cleanups in requestIdleCallback (#1470)

This commit is contained in:
Nolan Lawson 2019-09-07 20:27:54 -07:00 committed by GitHub
parent 26a036259e
commit d71d6b49ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@ import { createPinnedStatusKeyRange, createThreadKeyRange } from './keys'
import { getKnownInstances } from './knownInstances'
import noop from 'lodash-es/noop'
import { CLEANUP_DELAY, CLEANUP_TIME_AGO } from '../_static/database'
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
const BATCH_SIZE = 20
@ -134,8 +135,7 @@ export async function cleanup (instanceName) {
}
function doCleanup (instanceName) {
// run in setTimeout because we're in a worker and there's no requestIdleCallback
setTimeout(() => cleanup(instanceName))
scheduleIdleTask(() => cleanup(instanceName))
}
async function scheduledCleanup () {