Persistenten storage message hinzugefügt

This commit is contained in:
silas 2018-10-31 00:48:20 +01:00
parent b005de38b7
commit f4e477d03c

View File

@ -82,39 +82,39 @@ export class WordRotatorSettingFragment extends LocalStorageSettingsFragment {
installButton.classList.remove("hidden");
});
let storageManager = MyStorageManager.getInstance();
if (storageManager.canEstimateStorage()) {
console.log("can estimate storage!");
Promise.all([storageManager.estimate(), storageManager.isPersistent()]).then(res => {
let storage = res[0];
let isPersisted = res[1];
let storageObject = this.findBy("#storage-info");
console.log(isPersisted);
storageObject.appendChild(Translator.makePersistentTranslation("storage-info", [
Math.round(storage.usage / (1024 * 1024) * 100) / 100,
Math.round(storage.quota / (1024 * 1024) * 100) / 100,
Math.round(storage.usage / storage.quota * 10000) / 100,
((isPersisted) ? "" : "nicht")]));
storageObject.parentElement.classList.remove("hidden");
storageObject.parentElement.addEventListener("click", () => {
storageManager.persist().then(isPersisted => {
storageObject.removeAllChildren().appendChild(Translator.makePersistentTranslation("storage-info", [
Math.round(storage.usage / (1024 * 1024) * 100) / 100,
Math.round(storage.quota / (1024 * 1024) * 100) / 100,
Math.round(storage.usage / storage.quota * 10000) / 100,
((isPersisted) ? "" : "nicht")]));
console.log("p", isPersisted);
if (!isPersisted){
FlashMessenger.addMessage("storage-permission-not-get");
}
else {
FlashMessenger.addMessage("storage-permission-get");
}
});
})
});
}
// let storageManager = MyStorageManager.getInstance();
// if (storageManager.canEstimateStorage()) {
// console.log("can estimate storage!");
// Promise.all([storageManager.estimate(), storageManager.isPersistent()]).then(res => {
// let storage = res[0];
// let isPersisted = res[1];
// let storageObject = this.findBy("#storage-info");
// console.log(isPersisted);
// storageObject.appendChild(Translator.makePersistentTranslation("storage-info", [
// Math.round(storage.usage / (1024 * 1024) * 100) / 100,
// Math.round(storage.quota / (1024 * 1024) * 100) / 100,
// Math.round(storage.usage / storage.quota * 10000) / 100,
// ((isPersisted) ? "" : "nicht")]));
// storageObject.parentElement.classList.remove("hidden");
// storageObject.parentElement.addEventListener("click", () => {
// storageManager.persist().then(isPersisted => {
// storageObject.removeAllChildren().appendChild(Translator.makePersistentTranslation("storage-info", [
// Math.round(storage.usage / (1024 * 1024) * 100) / 100,
// Math.round(storage.quota / (1024 * 1024) * 100) / 100,
// Math.round(storage.usage / storage.quota * 10000) / 100,
// ((isPersisted) ? "" : "nicht")]));
//
// console.log("p", isPersisted);
// if (!isPersisted){
// FlashMessenger.addMessage("storage-permission-not-get");
// }
// else {
// FlashMessenger.addMessage("storage-permission-get");
// }
// });
// })
// });
// }
return super.onFirstStart();
}