about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2018-03-27 22:18:35 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-03-27 15:18:35 +0200
commitf5ed5f386020a08e8a659f4a6d25d2b875852be8 (patch)
tree43014a3cb070aad8fa5f7aff9aa520a027f97617 /app/javascript
parent2f3ac14a434c773577771b74292aa313d57db3c9 (diff)
Clone response before put it to the cache (#6932)
`Response.prototype.clone()` must be called before the response used.

This fixes an error from ServiceWorker and failing to load image when the
image is not cached.
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/service_worker/entry.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/javascript/mastodon/service_worker/entry.js b/app/javascript/mastodon/service_worker/entry.js
index b9cf06ef9..160c3fbf2 100644
--- a/app/javascript/mastodon/service_worker/entry.js
+++ b/app/javascript/mastodon/service_worker/entry.js
@@ -56,10 +56,10 @@ self.addEventListener('fetch', function(event) {
         const fetched = await fetch(event.request);
 
         if (fetched.ok) {
-          await cache.put(event.request.url, fetched);
+          await cache.put(event.request.url, fetched.clone());
         }
 
-        return fetched.clone();
+        return fetched;
       }
 
       return cached;