service worker fetch event for Add To Home Screen

This commit is contained in:
or-else
2018-10-30 22:31:10 +03:00
parent c2f261b143
commit 0198f446d4
2 changed files with 18 additions and 1 deletions
+16
View File
@@ -67,3 +67,19 @@ self.addEventListener('notificationclick', function(event) {
event.waitUntil(promises);
});
// This is needed for 'Add to Home Screen'.
self.addEventListener('fetch', function (event) {
event.respondWith(
// Try to find response in cache.
caches.match(event.request)
.then((resp) => {
// If response is found in cache, return it. Otherwise fetch.
return resp || fetch(event.request);
})
.catch((err) {
// Something went wrong.
console.error("Service worker Fetch: ", err);
})
);
});
+2 -1
View File
@@ -829,7 +829,8 @@ class TinodeWeb extends React.Component {
params.public = pub;
}
if (priv) {
params.private = {comment: priv};
params.private = (priv === Tinode.DEL_CHAR) ?
Tinode.DEL_CHAR : {comment: priv};
}
if (permissions) {
params.defacs = permissions;