chore: refactor cancel install logic

This commit is contained in:
userquin 2023-01-18 21:01:45 +01:00
parent b1876bc160
commit 0ce69d5399

View file

@ -76,6 +76,12 @@ export default defineNuxtPlugin(() => {
showInstallPrompt.value = false
})
const cancelInstall = () => {
deferredPrompt = undefined
showInstallPrompt.value = false
window.removeEventListener('beforeinstallprompt', beforeInstallPrompt)
}
const install = async () => {
if (!showInstallPrompt.value || !deferredPrompt) {
showInstallPrompt.value = false
@ -87,11 +93,7 @@ export default defineNuxtPlugin(() => {
deferredPrompt.prompt()
const { outcome } = await deferredPrompt.userChoice
if (outcome === 'dismissed')
window.removeEventListener('beforeinstallprompt', beforeInstallPrompt)
}
const cancelInstall = () => {
showInstallPrompt.value = false
cancelInstall()
}
return {