diff --git a/src/components/BreakoutRoomsEditor/SelectableParticipant.vue b/src/components/BreakoutRoomsEditor/SelectableParticipant.vue index f129885b163..6b1503cf3ea 100644 --- a/src/components/BreakoutRoomsEditor/SelectableParticipant.vue +++ b/src/components/BreakoutRoomsEditor/SelectableParticipant.vue @@ -15,6 +15,7 @@ :source="participant.source || participant.actorType" disable-menu disable-tooltip + :preloaded-user-status="preloadedUserStatus" show-user-status /> @@ -36,7 +37,7 @@ import IconCheck from 'vue-material-design-icons/Check.vue' import AvatarWrapper from '../AvatarWrapper/AvatarWrapper.vue' -import { getStatusMessage } from '../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.js' export default { name: 'SelectableParticipant', @@ -73,8 +74,12 @@ export default { }, }, + preloadedUserStatus() { + return getPreloadedUserStatus(this.participant) + }, + participantStatus() { - return getStatusMessage(this.participant) + return getStatusMessage(this.preloadedUserStatus) }, }, } diff --git a/src/components/ConversationIcon.vue b/src/components/ConversationIcon.vue index 069972eb772..1709d9e54a4 100644 --- a/src/components/ConversationIcon.vue +++ b/src/components/ConversationIcon.vue @@ -66,6 +66,7 @@ import { useIsDarkTheme } from '../composables/useIsDarkTheme.ts' import { AVATAR, CONVERSATION } from '../constants.js' import { getConversationAvatarOcsUrl } from '../services/avatarService.ts' import { hasTalkFeature } from '../services/CapabilitiesManager.ts' +import { getPreloadedUserStatus } from '../utils/userStatus.js' const supportsAvatar = hasTalkFeature('local', 'avatar') @@ -151,15 +152,11 @@ export default { }, preloadedUserStatus() { - if (!this.hideUserStatus && Object.prototype.hasOwnProperty.call(this.item, 'statusMessage')) { - // We preloaded the status - return { - status: this.item.status || null, - message: this.item.statusMessage || null, - icon: this.item.statusIcon || null, - } + if (this.hideUserStatus) { + return undefined } - return undefined + + return getPreloadedUserStatus(this.item) }, menuContainer() { diff --git a/src/components/RightSidebar/Participants/Participant.vue b/src/components/RightSidebar/Participants/Participant.vue index 06cda434ed8..3500be4aa70 100644 --- a/src/components/RightSidebar/Participants/Participant.vue +++ b/src/components/RightSidebar/Participants/Participant.vue @@ -371,7 +371,7 @@ import { import { hasTalkFeature } from '../../../services/CapabilitiesManager.ts' import { formattedTime } from '../../../utils/formattedTime.ts' import { readableNumber } from '../../../utils/readableNumber.ts' -import { getStatusMessage } from '../../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../../utils/userStatus.js' export default { name: 'Participant', @@ -546,7 +546,7 @@ export default { : '💬 ' + t('spreed', '{time} talking time', { time: formattedTime(this.timeSpeaking, true) }) } - return getStatusMessage(this.participant) + return getStatusMessage(this.preloadedUserStatus) }, /** @@ -826,23 +826,7 @@ export default { }, preloadedUserStatus() { - if (Object.prototype.hasOwnProperty.call(this.participant, 'statusMessage')) { - // We preloaded the status when via participants API - return { - status: this.participant.status || null, - message: this.participant.statusMessage || null, - icon: this.participant.statusIcon || null, - } - } - if (Object.prototype.hasOwnProperty.call(this.participant, 'status')) { - // We preloaded the status when via search API - return { - status: this.participant.status.status || null, - message: this.participant.status.message || null, - icon: this.participant.status.icon || null, - } - } - return undefined + return getPreloadedUserStatus(this.participant) }, attendeePermissions() { diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 2688c4ad369..49369b6484b 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -141,7 +141,7 @@ import { AVATAR, CONVERSATION } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useChatExtrasStore } from '../../stores/chatExtras.js' -import { getStatusMessage } from '../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.js' import { localCallParticipantModel, localMediaModel } from '../../utils/webrtc/index.js' export default { @@ -230,7 +230,7 @@ export default { }, statusMessage() { - return getStatusMessage(this.conversation) + return getStatusMessage(getPreloadedUserStatus(this.conversation)) }, renderedDescription() { diff --git a/src/utils/userStatus.js b/src/utils/userStatus.js index c455294cbb9..3510bb58be3 100644 --- a/src/utils/userStatus.js +++ b/src/utils/userStatus.js @@ -4,6 +4,31 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { t } from '@nextcloud/l10n' + +export function getPreloadedUserStatus(userData) { + if (!userData || typeof userData !== 'object') { + return undefined + } + + if ('statusMessage' in userData) { + // We preloaded the status when via participants API + return { + status: userData.status || null, + message: userData.statusMessage || null, + icon: userData.statusIcon || null, + } + } + if ('status' in userData && typeof userData.status === 'object') { + // We preloaded the status when via search API + return { + status: userData.status.status || null, + message: userData.status.message || null, + icon: userData.status.icon || null, + } + } + return undefined +} + /** * Generate full status message for user according to its status data * @@ -14,18 +39,18 @@ import { t } from '@nextcloud/l10n' * @return {string} */ export function getStatusMessage(userData) { - let status = userData.statusIcon - ? userData.statusIcon + ' ' - : '' + if (!userData) { + return '' + } + + let status = userData.icon ?? '' - if (userData.statusMessage) { - status += userData.statusMessage + if (userData.message) { + status += ' ' + userData.message } else if (userData.status === 'dnd') { - status += t('spreed', 'Do not disturb') + status += ' ' + t('spreed', 'Do not disturb') } else if (userData.status === 'away') { - status += t('spreed', 'Away') - } else { - status += '' + status += ' ' + t('spreed', 'Away') } return status