Skip to content

Commit

Permalink
Merge pull request #2053 from nextcloud/artonge/fix/fix_preview_in_in…
Browse files Browse the repository at this point in the history
…secure_env

Wrap cache query ni a try/catch
  • Loading branch information
artonge authored Sep 20, 2023
2 parents fc3c7d6 + 1012117 commit c165220
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 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.

11 changes: 8 additions & 3 deletions src/services/PreviewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ const SWCacheName = 'images'
* Check if the preview is already cached by the service worker
*
* @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 c165220

Please sign in to comment.