Skip to content
Snippets Groups Projects
Commit 3f433dab authored by Jonathan Weth's avatar Jonathan Weth :keyboard: Committed by root
Browse files

Merge pull request #329 from Katharineum/bugfix/offline-fallback

Bugfix/offline fallback
parents 9c3aea5e a1bb61b5
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -6,5 +6,5 @@
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (school-apps)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (SchoolApps)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -23,7 +23,7 @@
<excludeFolder url="file://$MODULE_DIR$/env" />
<excludeFolder url="file://$MODULE_DIR$/schoolapps/staticcollect" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7 (school-apps)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.7 (SchoolApps)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
......
......@@ -97,7 +97,7 @@ function cacheFirstFetch(event) {
// The response was not found in the cache so we look for it on the server
return fetch(event.request)
.then(function (response) {
// If request was success, add or update it in the cache
// If request was successful, add or update it in the cache
event.waitUntil(updateCache(event.request, response.clone()));
return response;
......@@ -121,12 +121,12 @@ function networkFirstFetch(event) {
event.respondWith(
fetch(event.request)
.then(function (response) {
// If request was success, add or update it in the cache
// If request was successful, add or update it in the cache
event.waitUntil(updateCache(event.request, response.clone()));
return response;
})
.catch(function (error) {
console.log("[SchoolApps PWA] Network request Failed. Serving content from cache: " + error);
console.log("[SchoolApps PWA] Network request failed. Serving content from cache: " + error);
return fromCache(event.request);
})
);
......@@ -135,11 +135,11 @@ function networkFirstFetch(event) {
function fromCache(request) {
// Check to see if you have it in the cache
// Return response
// If not in the cache, then return error page
// If not in the cache, then return offline fallback page
return caches.open(CACHE).then(function (cache) {
return cache.match(request).then(function (matching) {
if (!matching || matching.status === 404) {
return Promise.reject("no-match");
return caches.match(offlineFallbackPage);
}
return matching;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment