mirror of
https://github.com/GuerillaStudio/souvenir.git
synced 2025-01-20 18:50:21 +00:00
feat(notification): add done notification
This commit is contained in:
parent
93e8ad4b5f
commit
1d1ffe601e
2 changed files with 28 additions and 2 deletions
|
@ -24,6 +24,7 @@ import { encode } from '/services/encode.js'
|
||||||
import encodingScreen from '/views/screens/encoding'
|
import encodingScreen from '/views/screens/encoding'
|
||||||
import iconDl from '/views/icons/ico-download'
|
import iconDl from '/views/icons/ico-download'
|
||||||
import illuFlower from '/views/icons/flower'
|
import illuFlower from '/views/icons/flower'
|
||||||
|
import appLogo from '/assets/img/icons/android-chrome-512x512.png'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'download',
|
name: 'download',
|
||||||
|
@ -85,6 +86,19 @@ export default {
|
||||||
this.$store.commit('updateGif', gif)
|
this.$store.commit('updateGif', gif)
|
||||||
this.fillGIF()
|
this.fillGIF()
|
||||||
this.downloadReady = true
|
this.downloadReady = true
|
||||||
|
|
||||||
|
if (document.hidden && ('Notification' in window) && Notification.permission === 'granted') {
|
||||||
|
const notification = new Notification('You can now download your souvenir', {
|
||||||
|
body: 'Thank you for your patience.',
|
||||||
|
icon: appLogo
|
||||||
|
})
|
||||||
|
|
||||||
|
notification.addEventListener('click', () => {
|
||||||
|
parent.focus()
|
||||||
|
}, {
|
||||||
|
once: true
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="layoutOverlay-subtitle">{{ labelSubtitle }}</div>
|
<div class="layoutOverlay-subtitle">{{ labelSubtitle }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="encoding-notif">
|
<button v-if="showNotificationButton" class="encoding-notif" @click="noticeMeSenpai">
|
||||||
<icon-notif class="encoding-notif__icon"></icon-notif>
|
<icon-notif class="encoding-notif__icon"></icon-notif>
|
||||||
<div>Get notified when It’s done</div>
|
<div>Get notified when It’s done</div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -36,7 +36,8 @@ export default {
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
lastTitleUpdate: null,
|
lastTitleUpdate: null,
|
||||||
labelTitle: 'Encoding…'
|
labelTitle: 'Encoding…',
|
||||||
|
showNotificationButton: showNotificationButton()
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
percentage () {
|
percentage () {
|
||||||
|
@ -69,6 +70,11 @@ export default {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
noticeMeSenpai () {
|
||||||
|
Notification.requestPermission().then(() => {
|
||||||
|
this.showNotificationButton = showNotificationButton()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -77,4 +83,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showNotificationButton () {
|
||||||
|
return ('Notification' in window) &&
|
||||||
|
Notification.permission !== 'granted' &&
|
||||||
|
Notification.permission !== 'denied'
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue