refactor: use await for cache open in ximg-worker

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/672/head
Varun Patil 2023-05-26 09:13:52 -07:00
parent 10ff01ae86
commit 6b2e462496
1 changed files with 7 additions and 6 deletions

View File

@ -22,12 +22,13 @@ const pendingUrls = new Map<string, BlobCallback[]>();
// Cache for preview images
const cacheName = 'images';
let imageCache: Cache;
self.caches
?.open(cacheName)
.then((c) => (imageCache = c))
.catch((e) => {
console.warn('Failed to open cache in worker', e);
});
(async function openCache() {
try {
imageCache = await self.caches?.open(cacheName);
} catch {
console.warn('Failed to open cache in worker');
}
})();
// Expiration for cache
const expirationManager = new CacheExpiration(cacheName, {