Skip to content

Commit f096efe

Browse files
committed
Listen to user status changes and update the user status
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent bf6d132 commit f096efe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/NotificationsApp.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import Notification from './Components/Notification.vue'
9999
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
100100
import Close from 'vue-material-design-icons/Close.vue'
101101
import axios from '@nextcloud/axios'
102+
import { getCurrentUser } from '@nextcloud/auth'
102103
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
103104
import { showError } from '@nextcloud/dialogs'
104105
import { loadState } from '@nextcloud/initial-state'
@@ -233,20 +234,28 @@ export default {
233234
this.hasNotifyPush = true
234235
}
235236
236-
// Setup the background checker
237+
// Set up the background checker
237238
this._setPollingInterval(this.pollIntervalBase)
238239
239240
this._watchTabVisibility()
240241
subscribe('networkOffline', this.handleNetworkOffline)
241242
subscribe('networkOnline', this.handleNetworkOnline)
243+
subscribe('user_status:status.updated', this.userStatusUpdated)
242244
},
243245
244246
beforeDestroy() {
247+
unsubscribe('user_status:status.updated', this.userStatusUpdated)
245248
unsubscribe('networkOffline', this.handleNetworkOffline)
246249
unsubscribe('networkOnline', this.handleNetworkOnline)
247250
},
248251
249252
methods: {
253+
userStatusUpdated(state) {
254+
if (getCurrentUser().uid === state.userId) {
255+
this.userStatus = state.status
256+
}
257+
},
258+
250259
onOpen() {
251260
this.focusFirstFocusable()
252261
this.requestWebNotificationPermissions()

0 commit comments

Comments
 (0)