diff --git a/src/components/BreakoutRoomsEditor/SelectableParticipant.vue b/src/components/BreakoutRoomsEditor/SelectableParticipant.vue index 6b1503cf3ea..4658cbadaac 100644 --- a/src/components/BreakoutRoomsEditor/SelectableParticipant.vue +++ b/src/components/BreakoutRoomsEditor/SelectableParticipant.vue @@ -37,7 +37,7 @@ import IconCheck from 'vue-material-design-icons/Check.vue' import AvatarWrapper from '../AvatarWrapper/AvatarWrapper.vue' -import { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.ts' export default { name: 'SelectableParticipant', diff --git a/src/components/ConversationIcon.vue b/src/components/ConversationIcon.vue index 1709d9e54a4..bd61da75aa1 100644 --- a/src/components/ConversationIcon.vue +++ b/src/components/ConversationIcon.vue @@ -66,7 +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' +import { getPreloadedUserStatus } from '../utils/userStatus.ts' const supportsAvatar = hasTalkFeature('local', 'avatar') diff --git a/src/components/RightSidebar/Participants/Participant.vue b/src/components/RightSidebar/Participants/Participant.vue index 3500be4aa70..4591de3cf27 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 { getPreloadedUserStatus, getStatusMessage } from '../../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../../utils/userStatus.ts' export default { name: 'Participant', diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 49369b6484b..5e8c0d08e7f 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 { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.js' +import { getPreloadedUserStatus, getStatusMessage } from '../../utils/userStatus.ts' import { localCallParticipantModel, localMediaModel } from '../../utils/webrtc/index.js' export default { diff --git a/src/composables/useSortParticipants.js b/src/composables/useSortParticipants.js index c7a9e9a01b9..d78dff8b4da 100644 --- a/src/composables/useSortParticipants.js +++ b/src/composables/useSortParticipants.js @@ -8,7 +8,7 @@ import { computed } from 'vue' import { useStore } from './useStore.js' import { ATTENDEE, PARTICIPANT } from '../constants.js' -import { isDoNotDisturb } from '../utils/userStatus.js' +import { isDoNotDisturb } from '../utils/userStatus.ts' const MODERATOR_TYPES = [PARTICIPANT.TYPE.OWNER, PARTICIPANT.TYPE.MODERATOR, PARTICIPANT.TYPE.GUEST_MODERATOR] diff --git a/src/types/index.ts b/src/types/index.ts index 71147a5dd9e..d9b706301a8 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -55,7 +55,22 @@ export type JoinRoomFullResponse = { } // Participants +export type ParticipantStatus = { + status?: string | null, + message?: string | null, + icon?: string | null, + clearAt?: number | null, +} export type Participant = components['schemas']['Participant'] +export type ParticipantSearchResult = { + id: string, + label: string, + icon: string, + source: string, + subline: string, + shareWithDisplayNameUnique: string, + status: ParticipantStatus | '', +} // Chats export type Mention = RichObject<'server'|'call-type'|'icon-url'> diff --git a/src/utils/userStatus.js b/src/utils/userStatus.ts similarity index 65% rename from src/utils/userStatus.js rename to src/utils/userStatus.ts index 3510bb58be3..5a0af58051d 100644 --- a/src/utils/userStatus.js +++ b/src/utils/userStatus.ts @@ -5,7 +5,19 @@ */ import { t } from '@nextcloud/l10n' -export function getPreloadedUserStatus(userData) { +import type { + Conversation, + Participant, + ParticipantSearchResult, + ParticipantStatus, +} from '../types/index.ts' + +/** + * Generate user status object to use as preloaded status with NcAvatar + * + * @param userData user data (from conversation, participant, search result) + */ +export function getPreloadedUserStatus(userData?: Conversation | Participant | ParticipantSearchResult): ParticipantStatus | undefined { if (!userData || typeof userData !== 'object') { return undefined } @@ -32,13 +44,9 @@ export function getPreloadedUserStatus(userData) { /** * Generate full status message for user according to its status data * - * @param {object} userData user data - * @param {string} [userData.status] status of user - * @param {string} [userData.statusIcon] status icon of user - * @param {string} [userData.statusMessage] status message of user - * @return {string} + * @param userData user data (formatted via getPreloadedUserStatus() ) */ -export function getStatusMessage(userData) { +export function getStatusMessage(userData?: ParticipantStatus | ''): string { if (!userData) { return '' } @@ -59,10 +67,8 @@ export function getStatusMessage(userData) { /** * Check if current status is "Do not disturb" * - * @param {object} userData user data - * @param {string} [userData.status] status of user - * @return {boolean} + * @param userData user data */ -export function isDoNotDisturb(userData) { +export function isDoNotDisturb(userData: Conversation | Participant | ParticipantSearchResult): boolean { return userData?.status === 'dnd' }