Merge pull request #29313 from nextcloud/fix/status-menu-update

Fix status menu item not listening to status change events
This commit is contained in:
Carl Schwan 2021-10-20 16:00:38 +02:00 committed by GitHub
commit cf6bac8d6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 31 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -57,10 +57,10 @@
</template>
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state'
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>

View file

@ -165,6 +165,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
*