Install-button verschwindet nach abbruch
This commit is contained in:
parent
e7977aa487
commit
5a131ccee3
@ -4606,11 +4606,26 @@ InitPromise.addPromise(function(app){
|
|||||||
class InstallManager {
|
class InstallManager {
|
||||||
static init() {
|
static init() {
|
||||||
window.addEventListener('beforeinstallprompt', e => {
|
window.addEventListener('beforeinstallprompt', e => {
|
||||||
this.deferredPromt = e;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
this.setDeferredPrompt(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static setDeferredPrompt(e){
|
||||||
|
this.deferredPromt = e;
|
||||||
if (this.canInstallListener) {
|
if (this.canInstallListener) {
|
||||||
this.canInstallListener(this.deferredPromt);
|
this.canInstallListener(this.deferredPromt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async prompt(){
|
||||||
|
if (Helper.isNotNull(this.deferredPromt)){
|
||||||
|
this.deferredPromt.prompt();
|
||||||
|
return this.deferredPromt.userChoice();
|
||||||
|
}
|
||||||
|
return Promise.resolve({
|
||||||
|
"outcome":"dismissed",
|
||||||
|
"platform":""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6796,14 +6811,11 @@ class WordRotatorSettingFragment extends LocalStorageSettingsFragment {
|
|||||||
this.getSite().startSite(PrivacyPolicySite);
|
this.getSite().startSite(PrivacyPolicySite);
|
||||||
});
|
});
|
||||||
|
|
||||||
InstallManager.setCanInstallListener((e) => {
|
InstallManager.setCanInstallListener(() => {
|
||||||
let installButton = this.findBy("#install-button");
|
let installButton = this.findBy("#install-button");
|
||||||
installButton.addEventListener("click", () => {
|
installButton.addEventListener("click", () => {
|
||||||
e.prompt();
|
InstallManager.prompt().then(() => {
|
||||||
e["userChoice"].then(res => {
|
|
||||||
if (res["outcome"] === 'accepted') {
|
|
||||||
installButton.classList.add("hidden");
|
installButton.classList.add("hidden");
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
installButton.classList.remove("hidden");
|
installButton.classList.remove("hidden");
|
||||||
|
|||||||
@ -11,11 +11,26 @@ class DelayPromise extends Promise {
|
|||||||
class InstallManager {
|
class InstallManager {
|
||||||
static init() {
|
static init() {
|
||||||
window.addEventListener('beforeinstallprompt', e => {
|
window.addEventListener('beforeinstallprompt', e => {
|
||||||
this.deferredPromt = e;
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
this.setDeferredPrompt(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static setDeferredPrompt(e){
|
||||||
|
this.deferredPromt = e;
|
||||||
if (this.canInstallListener) {
|
if (this.canInstallListener) {
|
||||||
this.canInstallListener(this.deferredPromt);
|
this.canInstallListener(this.deferredPromt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async prompt(){
|
||||||
|
if (Helper.isNotNull(this.deferredPromt)){
|
||||||
|
this.deferredPromt.prompt();
|
||||||
|
return this.deferredPromt.userChoice();
|
||||||
|
}
|
||||||
|
return Promise.resolve({
|
||||||
|
"outcome":"dismissed",
|
||||||
|
"platform":""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,16 +61,11 @@ export class WordRotatorSettingFragment extends LocalStorageSettingsFragment {
|
|||||||
this.getSite().startSite(PrivacyPolicySite);
|
this.getSite().startSite(PrivacyPolicySite);
|
||||||
});
|
});
|
||||||
|
|
||||||
InstallManager.setCanInstallListener((e) => {
|
InstallManager.setCanInstallListener(() => {
|
||||||
console.log("can install!");
|
|
||||||
let installButton = this.findBy("#install-button");
|
let installButton = this.findBy("#install-button");
|
||||||
installButton.addEventListener("click", () => {
|
installButton.addEventListener("click", () => {
|
||||||
e.prompt();
|
InstallManager.prompt().then(() => {
|
||||||
e["userChoice"].then(res => {
|
|
||||||
console.log(res);
|
|
||||||
if (res["outcome"] === 'accepted') {
|
|
||||||
installButton.classList.add("hidden");
|
installButton.classList.add("hidden");
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
installButton.classList.remove("hidden");
|
installButton.classList.remove("hidden");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user