Create service worker in app

This commit is contained in:
Tusooa Zhu 2022-02-21 11:14:20 -05:00 committed by Sam Therapy
parent f907d68629
commit 003c31c0a1
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
3 changed files with 6 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import DesktopNav from './components/desktop_nav/desktop_nav.vue'
import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'
import PostStatusModal from './components/post_status_modal/post_status_modal.vue'
import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
import { getOrCreateServiceWorker } from './services/push/push'
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
import { mapGetters } from 'vuex'
@ -45,6 +46,7 @@ export default {
const val = this.$store.getters.mergedConfig.interfaceLanguage
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
window.addEventListener('resize', this.updateMobileState)
getOrCreateServiceWorker()
},
destroyed () {
window.removeEventListener('resize', this.updateMobileState)

View file

@ -109,3 +109,5 @@ export function unregisterPushNotifications (token) {
]).catch((e) => console.warn(`Failed to disable Web Push Notifications: ${e.message}`))
}
}
export { getOrCreateServiceWorker }

View file

@ -67,3 +67,5 @@ self.addEventListener('notificationclick', (event) => {
if (clients.openWindow) return clients.openWindow('/')
}))
})
self.addEventListener('fetch', _ => _)