Skip to content

Commit

Permalink
Fix status menu item not listening to status change events
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
CarlSchwan authored and skjnldsv committed Oct 20, 2021
1 parent 2083e1e commit 89112e5
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 30 deletions.
20 changes: 10 additions & 10 deletions apps/user_status/js/dashboard.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/user_status/js/dashboard.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions apps/user_status/js/user-status-menu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/user_status/js/user-status-menu.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/user_status/js/vendors-user-status-modal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/user_status/js/vendors-user-status-modal.js.map

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions apps/user_status/src/UserStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -149,6 +149,7 @@ export default {
this._backgroundHeartbeat()
}
subscribe('user_status:status.updated', this.handleUserStatusUpdated)
},
/**
Expand All @@ -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: {
Expand Down Expand Up @@ -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>
Expand Down
15 changes: 15 additions & 0 deletions apps/user_status/src/store/userStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 89112e5

Please sign in to comment.