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