Commit 4680476a authored by Cerdic's avatar Cerdic

et on ajoute le prompt de stockage persistent des que l'utilisateur demande en...

et on ajoute le prompt de stockage persistent des que l'utilisateur demande en telecharger hors-ligne
parent b6895860
......@@ -32,6 +32,7 @@ var offline = {
event.preventDefault();
var me = jQuery(this);
var src = me.attr('href');
offline.promptPersistent();
caches.open(offlineConfig.cacheName).then(function(cache) {
fetch(src).then(function(response) {
// put this in cache then we know this is already downloaded for offline
......@@ -50,16 +51,20 @@ var offline = {
});
},
promptPersistent : function() {
// TODO : https://storage.spec.whatwg.org/
// https://storage.spec.whatwg.org/
Promise.all([
navigator.storage.persisted(),
navigator.permissions.query({name: "persistent-storage"})
]).then(([persisted, permission]) => {
if(!persisted && permission.status == "granted") {
navigator.storage.persist().then( /* … */ )
} else if(!persistent && permission.status == "prompt") {
showPersistentStorageExplanation()
if(permission.state == "granted") {
// nothing to do !
} else if(permission.state == "prompt") {
// ask once
navigator.storage.persist();
} else if(permission.state == "denied") {
// tant pis ?
}
//console.log(persisted,permission);
})
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment