Fix ReferenceError when Cache API is missing ()

Cache API is not supported on Safari 11.0 / iOS 11.

Since those caching is optional, this patch simply ignores it.
This commit is contained in:
unarist 2018-03-29 21:57:02 +09:00 committed by Eugen Rochko
parent 41452e8302
commit f1f846045f
1 changed files with 4 additions and 1 deletions
app/javascript/mastodon/storage

View File

@ -4,7 +4,10 @@ import { autoPlayGif } from '../initial_state';
const accountAssetKeys = ['avatar', 'avatar_static', 'header', 'header_static']; const accountAssetKeys = ['avatar', 'avatar_static', 'header', 'header_static'];
const avatarKey = autoPlayGif ? 'avatar' : 'avatar_static'; const avatarKey = autoPlayGif ? 'avatar' : 'avatar_static';
const limit = 1024; 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) { function put(name, objects, onupdate, oncreate) {
return asyncDB.then(db => new Promise((resolve, reject) => { return asyncDB.then(db => new Promise((resolve, reject) => {