Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/NcAvatar/NcAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,12 @@ export default {
if (!this.preloadedUserStatus) {
this.fetchUserStatus(this.user)
} else {
this.userStatus.status = this.preloadedUserStatus.status || ''
this.userStatus.message = this.preloadedUserStatus.message || ''
this.userStatus.icon = this.preloadedUserStatus.icon || ''
this.hasStatus = this.preloadedUserStatus.status !== null
this.setUserStatus(this.preloadedUserStatus)
}
subscribe('user_status:status.updated', this.handleUserStatusUpdated)
} else if (!this.hideStatus && this.preloadedUserStatus) {
// Always set preloaded status if provided
this.setUserStatus(this.preloadedUserStatus)
}
},

Expand Down Expand Up @@ -781,7 +781,7 @@ export default {
this.isAvatarLoaded = false

/** Only run avatar image loading if either user or url property is defined */
if (!this.isUrlDefined && (!this.isUserDefined || this.isNoUser || this.iconClass)) {
if (!this.isUrlDefined && (!this.isUserDefined || this.isNoUser || this.iconClass || this.$slots.icon)) {
this.isAvatarLoaded = true
this.userDoesNotExist = true
return
Expand Down
24 changes: 15 additions & 9 deletions src/mixins/userStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ export default {

try {
const { data } = await axios.get(generateOcsUrl('apps/user_status/api/v1/statuses/{userId}', { userId }))
const {
status,
message,
icon,
} = data.ocs.data
this.userStatus.status = status
this.userStatus.message = message || ''
this.userStatus.icon = icon || ''
this.hasStatus = true
this.setUserStatus(data.ocs.data)
} catch (e) {
if (e.response.status === 404 && e.response.data.ocs?.data?.length === 0) {
// User just has no status set, so don't log it
Expand All @@ -61,5 +53,19 @@ export default {
logger.error('Failed to fetch user status', { error: e })
}
},

/**
* Sets the user status
*
* @param {string} status user's status
* @param {string} message user's message
* @param {string} icon user's icon
*/
setUserStatus({ status, message, icon }) {
this.userStatus.status = status || ''
this.userStatus.message = message || ''
this.userStatus.icon = icon || ''
this.hasStatus = !!status
},
},
}
Loading