From 7aa99f6f19ec8cf4be4136242e42d36cb6ec460b Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 26 Jun 2017 18:07:20 -0700 Subject: [PATCH 1/2] Approach cache more defensively --- bin/template/www/cordova-sw.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/template/www/cordova-sw.js b/bin/template/www/cordova-sw.js index 0cb2cafe..72a926a5 100644 --- a/bin/template/www/cordova-sw.js +++ b/bin/template/www/cordova-sw.js @@ -19,5 +19,9 @@ this.addEventListener('activate', function(event) { this.addEventListener('fetch', function(event) { console.log("cordova service worker : fetch : " + event.request.url); - event.respondWith(caches.match(event.request)); + + event.respondWith(caches.match(event.request).then(function(response) { + // Cache hit? return response else fetch it + return response || fetch(event.request); + })); }); From b7ac532a06f3aea72bb45d5e6b8c7c36ed48cbcd Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 26 Jun 2017 18:08:21 -0700 Subject: [PATCH 2/2] use white as default bgcolor in manifest, map unknown orientation values to 'any', address some issues raised in #32 --- bin/template/cordova/Api.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js index 3b1ea8e3..9858366d 100644 --- a/bin/template/cordova/Api.js +++ b/bin/template/cordova/Api.js @@ -162,7 +162,7 @@ Api.prototype.prepare = function (cordovaProject,options) { } else { var manifestJson = { - "background_color": "#000", + "background_color": "#FFF", "display": "standalone" }; if(this.config){ @@ -208,8 +208,14 @@ Api.prototype.prepare = function (cordovaProject,options) { // orientation // var oriPref = this.config.getGlobalPreference('Orientation'); - if(oriPref && ["landscape","portrait"].indexOf(oriPref) > -1) { - manifestJson.orientation = oriPref; + if(oriPref) { + // if it's a supported value, use it + if(["landscape","portrait"].indexOf(oriPref) > -1) { + manifestJson.orientation = oriPref; + } + else { // anything else maps to 'any' + manifestJson.orientation = 'any'; + } } // get start_url