588b4f507a
Fix redirect to home Move redirect to home to no auth component Move setup stuff to separate functions Renew token in authenticated component Use vue's router object Move auth type checks to computed properties Move after route stuff to authenticated content component More Cleanup Cleanup Hide the navigation on mobile in the navigation component Load namespaces from inside the navigation component Fix logout Move not authenticated content to separate component Fix favoriting lists Move link share authenticated stuff to separate component Move authenticated stuff to separate component Move side navigation to separate component Move top navigation bar to separate component Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/283 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
49 lines
1.1 KiB
Vue
49 lines
1.1 KiB
Vue
<template>
|
|
<div class="update-notification" v-if="updateAvailable">
|
|
<p>There is an update for Vikunja available!</p>
|
|
<a @click="refreshApp()" class="button is-primary noshadow">Update Now</a>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import swEvents from '@/ServiceWorker/events.json'
|
|
|
|
export default {
|
|
name: 'update',
|
|
data() {
|
|
return {
|
|
updateAvailable: false,
|
|
registration: null,
|
|
refreshing: false,
|
|
}
|
|
},
|
|
created() {
|
|
document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true})
|
|
|
|
if (navigator && navigator.serviceWorker) {
|
|
navigator.serviceWorker.addEventListener(
|
|
'controllerchange', () => {
|
|
if (this.refreshing) return
|
|
this.refreshing = true
|
|
window.location.reload()
|
|
},
|
|
)
|
|
}
|
|
},
|
|
methods: {
|
|
showRefreshUI(e) {
|
|
console.log('recieved refresh event', e)
|
|
this.registration = e.detail
|
|
this.updateAvailable = true
|
|
},
|
|
refreshApp() {
|
|
this.updateExists = false
|
|
if (!this.registration || !this.registration.waiting) {
|
|
return
|
|
}
|
|
// Notify the service worker to actually do the update
|
|
this.registration.waiting.postMessage('skipWaiting')
|
|
},
|
|
},
|
|
}
|
|
</script>
|