Skip to content

Commit

Permalink
fix(files): window.caches check
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Aug 16, 2023
1 parent 3df65c6 commit 89acd13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions apps/files/src/services/PreviewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ const SWCacheName = 'previews'
/**
* Check if the preview is already cached by the service worker
*/
export const isCachedPreview = function(previewUrl: string) {
return caches.open(SWCacheName)
export const isCachedPreview = function(previewUrl: string): Promise<boolean> {
if (!window?.caches?.open) {
return Promise.resolve(false)
}

return window?.caches?.open(SWCacheName)
.then(function(cache) {
return cache.match(previewUrl)
.then(function(response) {
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

0 comments on commit 89acd13

Please sign in to comment.