diff options
Diffstat (limited to 'apps/user_status/src')
-rw-r--r-- | apps/user_status/src/UserStatus.vue | 15 | ||||
-rw-r--r-- | apps/user_status/src/store/userStatus.js | 15 |
2 files changed, 28 insertions, 2 deletions
diff --git a/apps/user_status/src/UserStatus.vue b/apps/user_status/src/UserStatus.vue index b4f1a847c0a..608966b9d9a 100644 --- a/apps/user_status/src/UserStatus.vue +++ b/apps/user_status/src/UserStatus.vue @@ -57,10 +57,10 @@ </template> <script> +import { generateUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' -import { subscribe, unsubscribe } from '@nextcloud/event-bus' import { loadState } from '@nextcloud/initial-state' -import { generateUrl } from '@nextcloud/router' +import { subscribe, unsubscribe } from '@nextcloud/event-bus' import debounce from 'debounce' import { sendHeartbeat } from './services/heartbeatService' @@ -149,6 +149,7 @@ export default { this._backgroundHeartbeat() } + subscribe('user_status:status.updated', this.handleUserStatusUpdated) }, /** @@ -159,6 +160,7 @@ export default { unsubscribe('settings:profile-enabled:updated', this.handleProfileEnabledUpdate) window.removeEventListener('mouseMove', this.mouseMoveListener) clearInterval(this.heartbeatInterval) + unsubscribe('user_status:status.updated', this.handleUserStatusUpdated) }, methods: { @@ -207,6 +209,15 @@ export default { console.debug('Failed sending heartbeat, got: ' + error.response?.status) } }, + handleUserStatusUpdated(state) { + if (OC.getCurrentUser().uid === state.userId) { + this.$store.dispatch('setStatusFromObject', { + status: state.status, + icon: state.icon, + message: state.message, + }) + } + }, }, } </script> diff --git a/apps/user_status/src/store/userStatus.js b/apps/user_status/src/store/userStatus.js index f1910d23354..99761da1265 100644 --- a/apps/user_status/src/store/userStatus.js +++ b/apps/user_status/src/store/userStatus.js @@ -166,6 +166,21 @@ const actions = { }, /** + * Update status from 'user_status:status.updated' update. + * This doesn't trigger another 'user_status:status.updated' + * event. + * + * @param {Object} vuex The Vuex destructuring object + * @param {Function} vuex.commit The Vuex commit function + * @param {Object} vuex.state The Vuex state object + * @param {String} status The new status + * @returns {Promise<void>} + */ + async setStatusFromObject({ commit, state }, status) { + commit('loadStatusFromServer', status) + }, + + /** * Sets a message using a predefined message * * @param {Object} vuex The Vuex destructuring object |