This commit is contained in:
silas 2018-11-01 12:44:58 +01:00
parent bcd5328b80
commit c86eb5f1c8
3 changed files with 102 additions and 68 deletions

View File

@ -7328,40 +7328,39 @@ 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();
} }
@ -7573,3 +7572,21 @@ InitPromise.resolve(app$1).then(async function () {
window["applyAndroidBridge"] = AndroidBridge.applyDefinitions; window["applyAndroidBridge"] = AndroidBridge.applyDefinitions;
}); });
console.log("trying push... 1");
navigator.serviceWorker["ready"].then(function (registration) {
console.log("trying push... 2");
registration["pushManager"]["subscribe"]({
"userVisibleOnly": false,
"applicationServerKey": new Uint8Array([0x4, 0x53, 0xb7, 0x8d, 0xc6, 0xd1, 0x1a, 0xd4, 0x8b, 0xb2, 0xeb, 0x82, 0xf0, 0x9e, 0x12, 0xf6, 0xd, 0x32, 0x18, 0xa, 0x35, 0xf, 0x2d, 0x4c, 0x5, 0x29, 0x15, 0x95, 0x23, 0xb1, 0xd3, 0xab, 0x87, 0x88, 0x85, 0x1d, 0xc0, 0x98, 0x6e, 0x65, 0xe3, 0xcb, 0xa2, 0x28, 0x63, 0x7, 0x34, 0x9b, 0xfa, 0x46, 0x9a, 0x49, 0xcc, 0x70, 0x7a, 0xdd, 0xbe, 0x1e, 0xfc, 0xde, 0xcc, 0xb3, 0x5b, 0xcb, 0xf4])
}).then(function (sub) {
console.log("trying push... 3");
console.log("Subscription", sub);
}).catch(function (e) {
// if ('Notification' in window && Notification.permission === 'denied') {
// console.warn('Permission for notifications was denied');
// } else {
// console.error('Unable to subscribe to push', e);
// }
});
});

View File

@ -94,3 +94,21 @@ InitPromise.resolve(app).then(async function () {
window["applyAndroidBridge"] = AndroidBridge.applyDefinitions; window["applyAndroidBridge"] = AndroidBridge.applyDefinitions;
}); });
console.log("trying push... 1");
navigator.serviceWorker["ready"].then(function (registration) {
console.log("trying push... 2");
registration["pushManager"]["subscribe"]({
"userVisibleOnly": false,
"applicationServerKey": new Uint8Array([0x4, 0x53, 0xb7, 0x8d, 0xc6, 0xd1, 0x1a, 0xd4, 0x8b, 0xb2, 0xeb, 0x82, 0xf0, 0x9e, 0x12, 0xf6, 0xd, 0x32, 0x18, 0xa, 0x35, 0xf, 0x2d, 0x4c, 0x5, 0x29, 0x15, 0x95, 0x23, 0xb1, 0xd3, 0xab, 0x87, 0x88, 0x85, 0x1d, 0xc0, 0x98, 0x6e, 0x65, 0xe3, 0xcb, 0xa2, 0x28, 0x63, 0x7, 0x34, 0x9b, 0xfa, 0x46, 0x9a, 0x49, 0xcc, 0x70, 0x7a, 0xdd, 0xbe, 0x1e, 0xfc, 0xde, 0xcc, 0xb3, 0x5b, 0xcb, 0xf4])
}).then(function (sub) {
console.log("trying push... 3");
console.log("Subscription", sub);
}).catch(function (e) {
// if ('Notification' in window && Notification.permission === 'denied') {
// console.warn('Permission for notifications was denied');
// } else {
// console.error('Unable to subscribe to push', e);
// }
});
});

View File

@ -82,40 +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();
} }