@@ -103,7 +103,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
103103import Close from ' vue-material-design-icons/Close.vue'
104104import axios from ' @nextcloud/axios'
105105import { getCurrentUser } from ' @nextcloud/auth'
106- import { subscribe , unsubscribe } from ' @nextcloud/event-bus'
106+ import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
107107import { showError } from ' @nextcloud/dialogs'
108108import { loadState } from ' @nextcloud/initial-state'
109109import {
@@ -117,6 +117,7 @@ import Message from 'vue-material-design-icons/Message.vue'
117117import NcEmptyContent from ' @nextcloud/vue/dist/Components/NcEmptyContent.js'
118118import { getCapabilities } from ' @nextcloud/capabilities'
119119import NcHeaderMenu from ' @nextcloud/vue/dist/Components/NcHeaderMenu.js'
120+ import { createWebNotification } from ' ./services/webNotificationsService.js'
120121
121122export default {
122123 name: ' NotificationsApp' ,
@@ -398,6 +399,7 @@ export default {
398399 this .lastETag = response .headers .etag
399400 this .lastTabId = response .tabId
400401 this .notifications = response .data
402+ this .processWebNotifications (response .data )
401403 console .debug (' Got notification data, restoring default polling interval.' )
402404 this ._setPollingInterval (this .pollIntervalBase )
403405 this ._updateDocTitleOnNewNotifications (this .notifications )
@@ -514,6 +516,21 @@ export default {
514516 this .webNotificationsGranted = permissions === ' granted'
515517 })
516518 },
519+
520+ processWebNotifications (notifications ) {
521+ notifications .forEach (notification => {
522+ if (this .backgroundFetching ) {
523+ // Can not rely on showBrowserNotifications because each tab should
524+ // be able to utilize the data from the notification in events.
525+ const event = { notification }
526+ emit (' notifications:notification:received' , event )
527+ }
528+
529+ if (this .showBrowserNotifications && this .webNotificationsThresholdId < notification .notificationId ) {
530+ createWebNotification (notification)
531+ }
532+ })
533+ },
517534 },
518535}
519536< / script>
0 commit comments