Skip to content

Commit

Permalink
Merge pull request #2112 from nextcloud/artonge/backport/stable27/2053
Browse files Browse the repository at this point in the history
[stable27] Wrap cache query in a try/catch
  • Loading branch information
artonge authored Nov 14, 2023
2 parents 14e68cf + 7e098ea commit 0cb4655
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 0cb4655

Please sign in to comment.