Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Oct 24, 2022
1 parent 1e0131b commit 7b5aa00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
const makeCachesDeleteMock = (keys: string[]) => {
return jest
.fn()
.mockImplementation(key => Promise.resolve(keys.includes(key)))
.mockImplementation((key) => Promise.resolve(keys.includes(key)))
}

const keysMockDefault = jest.fn().mockImplementation(async () => [])
Expand Down
16 changes: 8 additions & 8 deletions services/offline/src/lib/clear-sensitive-caches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ const clearDB = async (dbName: string): Promise<void> => {
return new Promise((resolve, reject) => {
// IndexedDB fun:
const openDBRequest = indexedDB.open(dbName)
openDBRequest.onsuccess = e => {
openDBRequest.onsuccess = (e) => {
const db = (e.target as IDBOpenDBRequest).result
const tx = db.transaction(SECTIONS_STORE, 'readwrite')
// When the transaction completes is when the operation is done:
tx.oncomplete = () => resolve()
tx.onerror = e => reject((e.target as IDBRequest).error)
tx.onerror = (e) => reject((e.target as IDBRequest).error)
const os = tx.objectStore(SECTIONS_STORE)
const clearReq = os.clear()
clearReq.onerror = e => reject((e.target as IDBRequest).error)
clearReq.onerror = (e) => reject((e.target as IDBRequest).error)
}
openDBRequest.onerror = e => {
openDBRequest.onerror = (e) => {
reject((e.target as IDBOpenDBRequest).error)
}
})
Expand Down Expand Up @@ -77,16 +77,16 @@ export async function clearSensitiveCaches(
// (Resolves to 'false' because this can't detect if anything was deleted):
clearDB(dbName).then(() => false),
// Remove caches if not in keepable list
...cacheKeys.map(key => {
if (!KEEPABLE_CACHES.some(pattern => pattern.test(key))) {
...cacheKeys.map((key) => {
if (!KEEPABLE_CACHES.some((pattern) => pattern.test(key))) {
return caches.delete(key)
}
return false
}),
]).then(responses => {
]).then((responses) => {
// Return true if any caches have been cleared
// (caches.delete() returns true if a cache is deleted successfully)
// PWA apps can reload to restore their app shell cache
return responses.some(response => response)
return responses.some((response) => response)
})
}

0 comments on commit 7b5aa00

Please sign in to comment.