Skip to content

Commit

Permalink
Wrap cache query ni a try/catch
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Nov 6, 2023
1 parent f0c8446 commit 7e098ea
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/services/PreviewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ const SWCacheName = 'images'
/**
* Check if the preview is already cached by the service worker
*
* @param {string} previewUrl
* @param {string} previewUrl - The URL of the preview to check
* @return {Promise<boolean>}
*/
export const isCachedPreview = async function(previewUrl) {
const cache = await window.caches?.open(SWCacheName)
const response = await cache?.match(previewUrl)
return response !== undefined
try {
const cache = await window.caches?.open(SWCacheName)
const response = await cache?.match(previewUrl)
return response !== undefined
} catch {
return false
}
}

0 comments on commit 7e098ea

Please sign in to comment.