Create service worker in app

This commit is contained in:
Tusooa Zhu 2022-02-21 11:14:20 -05:00 committed by tusooa
commit a959104333
No known key found for this signature in database
GPG key ID: 42AEC43D48433C51
3 changed files with 5 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import EditStatusModal from './components/edit_status_modal/edit_status_modal.vu
import PostStatusModal from './components/post_status_modal/post_status_modal.vue' import PostStatusModal from './components/post_status_modal/post_status_modal.vue'
import StatusHistoryModal from './components/status_history_modal/status_history_modal.vue' import StatusHistoryModal from './components/status_history_modal/status_history_modal.vue'
import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue' import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
import { getOrCreateServiceWorker } from './services/sw/sw'
import { windowWidth, windowHeight } from './services/window_utils/window_utils' import { windowWidth, windowHeight } from './services/window_utils/window_utils'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { defineAsyncComponent } from 'vue' import { defineAsyncComponent } from 'vue'
@ -65,6 +66,7 @@ export default {
if (useInterfaceStore().themeApplied) { if (useInterfaceStore().themeApplied) {
this.removeSplash() this.removeSplash()
} }
getOrCreateServiceWorker()
}, },
unmounted () { unmounted () {
window.removeEventListener('resize', this.updateMobileState) window.removeEventListener('resize', this.updateMobileState)

View file

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

View file

@ -143,4 +143,4 @@ self.addEventListener('notificationclick', (event) => {
})) }))
}) })
console.log('sw here') self.addEventListener('fetch', _ => _)