]> cat aescling's git repositories - mastodon.git/commitdiff
Fix ReferenceError when Cache API is missing (#6953)
authorunarist <m.unarist@gmail.com>
Thu, 29 Mar 2018 12:57:02 +0000 (21:57 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 29 Mar 2018 12:57:02 +0000 (14:57 +0200)
Cache API is not supported on Safari 11.0 / iOS 11.

Since those caching is optional, this patch simply ignores it.

app/javascript/mastodon/storage/modifier.js

index 63e49fe6edf25471e6c86e12fdcb9f7bb3632b7f..1bec04d0fdab1350a487a941d845537acff6691c 100644 (file)
@@ -4,7 +4,10 @@ import { autoPlayGif } from '../initial_state';
 const accountAssetKeys = ['avatar', 'avatar_static', 'header', 'header_static'];
 const avatarKey = autoPlayGif ? 'avatar' : 'avatar_static';
 const limit = 1024;
-const asyncCache = caches.open('mastodon-system');
+
+// ServiceWorker and Cache API is not available on iOS 11
+// https://webkit.org/status/#specification-service-workers
+const asyncCache = window.caches ? caches.open('mastodon-system') : Promise.reject();
 
 function put(name, objects, onupdate, oncreate) {
   return asyncDB.then(db => new Promise((resolve, reject) => {