aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/src
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-10-19 10:57:30 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2021-10-20 10:21:23 +0200
commit89112e5df95d70967793a874d4aad56326e35676 (patch)
tree409273f2ad92d4efbb2ca4d945d2f2587c39abce /apps/user_status/src
parent2083e1ede253a6ea76f67d37c382cd851620ad99 (diff)
downloadnextcloud-server-89112e5df95d70967793a874d4aad56326e35676.tar.gz
nextcloud-server-89112e5df95d70967793a874d4aad56326e35676.zip
Fix status menu item not listening to status change events
This makes it so that the status menu item listens to user_status:status.updated events even when they are triggered outside of the user status modal. Signed-off-by: Carl Schwan <carl@carlschwan.eu> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/user_status/src')
-rw-r--r--apps/user_status/src/UserStatus.vue15
-rw-r--r--apps/user_status/src/store/userStatus.js15
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