diff --git a/src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue b/src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue index 8774914f4be..ce77c63897d 100644 --- a/src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue +++ b/src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue @@ -97,7 +97,7 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js' import BreakoutRoomsParticipantsEditor from './BreakoutRoomsParticipantsEditor.vue' -import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts' export default { name: 'BreakoutRoomsEditor', diff --git a/src/components/BreakoutRoomsEditor/BreakoutRoomsParticipantsEditor.vue b/src/components/BreakoutRoomsEditor/BreakoutRoomsParticipantsEditor.vue index ee432733a9f..39e2b523236 100644 --- a/src/components/BreakoutRoomsEditor/BreakoutRoomsParticipantsEditor.vue +++ b/src/components/BreakoutRoomsEditor/BreakoutRoomsParticipantsEditor.vue @@ -119,7 +119,7 @@ import SelectableParticipant from './SelectableParticipant.vue' import BreakoutRoomItem from '../RightSidebar/BreakoutRooms/BreakoutRoomItem.vue' import { ATTENDEE, CONVERSATION, PARTICIPANT } from '../../constants.js' -import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts' export default { name: 'BreakoutRoomsParticipantsEditor', diff --git a/src/components/NewMessage/NewMessage.vue b/src/components/NewMessage/NewMessage.vue index fe87312dc48..325e3265796 100644 --- a/src/components/NewMessage/NewMessage.vue +++ b/src/components/NewMessage/NewMessage.vue @@ -224,7 +224,7 @@ import BrowserStorage from '../../services/BrowserStorage.js' import { EventBus } from '../../services/EventBus.js' import { shareFile } from '../../services/filesSharingServices.js' import { searchPossibleMentions } from '../../services/mentionsService.js' -import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts' import { useChatExtrasStore } from '../../stores/chatExtras.js' import { useSettingsStore } from '../../stores/settings.js' import { fetchClipboardContent } from '../../utils/clipboard.js' diff --git a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue index 7ff6fd03b11..2451cad4295 100644 --- a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue +++ b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue @@ -93,7 +93,7 @@ import SendMessageDialog from '../../BreakoutRoomsEditor/SendMessageDialog.vue' import { CONVERSATION, PARTICIPANT } from '../../../constants.js' import { EventBus } from '../../../services/EventBus.js' -import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.ts' export default { name: 'BreakoutRoomItem', diff --git a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsActions.vue b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsActions.vue index a1a2441cf22..4f9e6362891 100644 --- a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsActions.vue +++ b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsActions.vue @@ -124,7 +124,7 @@ import SendMessageDialog from '../../BreakoutRoomsEditor/SendMessageDialog.vue' import { useIsInCall } from '../../../composables/useIsInCall.js' import { CONVERSATION, PARTICIPANT } from '../../../constants.js' import { EventBus } from '../../../services/EventBus.js' -import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.ts' export default { name: 'BreakoutRoomsActions', diff --git a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue index 41485c64349..55ece4c683e 100644 --- a/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue +++ b/src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue @@ -58,7 +58,7 @@ import BreakoutRoomsActions from './BreakoutRoomsActions.vue' import Participant from '../Participants/Participant.vue' import { CONVERSATION, PARTICIPANT } from '../../../constants.js' -import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.ts' export default { name: 'BreakoutRoomsTab', diff --git a/src/components/TopBar/CallButton.vue b/src/components/TopBar/CallButton.vue index 108b78e45c8..e8f44536e43 100644 --- a/src/components/TopBar/CallButton.vue +++ b/src/components/TopBar/CallButton.vue @@ -116,7 +116,7 @@ import { useIsInCall } from '../../composables/useIsInCall.js' import { ATTENDEE, CALL, CONVERSATION, PARTICIPANT } from '../../constants.js' import { callSIPDialOut } from '../../services/callsService.js' import { EventBus } from '../../services/EventBus.js' -import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts' import { useSettingsStore } from '../../stores/settings.js' import { useTalkHashStore } from '../../stores/talkHash.js' import { blockCalls, unsupportedWarning } from '../../utils/browserCheck.js' diff --git a/src/components/TopBar/TopBarMenu.vue b/src/components/TopBar/TopBarMenu.vue index 01d5a3bc654..ddbe4e6bba0 100644 --- a/src/components/TopBar/TopBarMenu.vue +++ b/src/components/TopBar/TopBarMenu.vue @@ -190,7 +190,7 @@ import PromotedView from '../../assets/missingMaterialDesignIcons/PromotedView.v import { useIsInCall } from '../../composables/useIsInCall.js' import { CALL, CONVERSATION, PARTICIPANT } from '../../constants.js' -import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts' import { generateAbsoluteUrl } from '../../utils/handleUrl.ts' import { callParticipantCollection } from '../../utils/webrtc/index.js' diff --git a/src/services/breakoutRoomsService.js b/src/services/breakoutRoomsService.js index 6457b115310..e69de29bb2d 100644 --- a/src/services/breakoutRoomsService.js +++ b/src/services/breakoutRoomsService.js @@ -1,178 +0,0 @@ -/** - * @copyright Copyright (c) 2022 Marco Ambrosini - * - * @author Marco Ambrosini - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -import axios from '@nextcloud/axios' -import { generateOcsUrl } from '@nextcloud/router' - -/** - * Create breakout rooms for a given conversation - * - * @param {string} token The conversation token - * @param {string} mode Either manual, auto, or free, see constants file - * @param {number} amount The amount of breakout rooms to be created - * @param {string} attendeeMap A json encoded Map of attendeeId => room number (0 based) - * (Only considered when the mode is "manual") - * @return {Promise>} - */ -const configureBreakoutRooms = async function(token, mode, amount, attendeeMap) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}', { token }), { - mode, - amount, - attendeeMap, - }) -} - -/** - * Resets the request assistance - * - * @param {string} token the breakout room token - * @param {string} attendeeMap A json encoded Map of attendeeId => room number (0 based) - * @return {Promise>} The array of conversations - */ -const reorganizeAttendees = async function(token, attendeeMap) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/attendees', { - token, - }), { - attendeeMap, - } - ) -} - -/** - * Deletes all breakout rooms for a given conversation - * - * @param {string} token The conversation token - * @return {Promise>} - */ -const deleteBreakoutRooms = async function(token) { - return await axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}', { token })) -} - -/** - * Fetches the breakout rooms for given conversation - * - * @param {string} token The conversation token - * @return {Promise>} The array of conversations - */ -const getBreakoutRooms = async function(token) { - return await axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms', { token })) -} - -/** - * - * @param {string} token The conversation token - * @return {Promise>} The array of conversations - */ -const startBreakoutRooms = async function(token) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/rooms', { token })) -} - -/** - * Stops the breakout rooms - * - * @param {string} token The conversation token - * @return {Promise>} The array of conversations - */ -const stopBreakoutRooms = async function(token) { - return await axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/rooms', { token })) -} - -/** - * @param {string} token the conversation token - * @param {string} message The message to be posted - * @return {Promise>} The array of conversations - */ -const broadcastMessageToBreakoutRooms = async function(token, message) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/broadcast', { - token, - }), { - message, - token, - }) -} - -/** - * - * @param {string} token the conversation token - * @return {Promise>} The array of conversations - */ -const fetchBreakoutRoomsParticipants = async function(token) { - return await axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms/participants', { - token, - })) -} - -/** - * Requests assistance from a moderator - * - * @param {string} token the breakout room token - * @return {Promise>} The array of conversations - */ -const requestAssistance = async function(token) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', { - token, - }) - ) -} - -/** - * Resets the request assistance - * - * @param {string} token the breakout room token - * @return {Promise>} The array of conversations - */ -const dismissRequestAssistance = async function(token) { - return await axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', { - token, - }) - ) -} - -/** - * This endpoint allows participants to switch between breakout rooms when they are allowed to choose the breakout room - * and not are automatically or manually assigned by the moderator. - * - * @param {string} token Conversation token of the parent room hosting the breakout rooms - * @param {string} target Conversation token of the target breakout room - * @return {Promise>} The target breakout room - */ -const switchToBreakoutRoom = async function(token, target) { - return await axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/switch', { - token, - }), { - target, - } - ) -} - -export { - configureBreakoutRooms, - reorganizeAttendees, - deleteBreakoutRooms, - getBreakoutRooms, - startBreakoutRooms, - stopBreakoutRooms, - broadcastMessageToBreakoutRooms, - fetchBreakoutRoomsParticipants, - requestAssistance, - dismissRequestAssistance, - switchToBreakoutRoom, -} diff --git a/src/services/breakoutRoomsService.ts b/src/services/breakoutRoomsService.ts new file mode 100644 index 00000000000..4f007f918cb --- /dev/null +++ b/src/services/breakoutRoomsService.ts @@ -0,0 +1,166 @@ +/** + * @copyright Copyright (c) 2022 Marco Ambrosini + * + * @author Marco Ambrosini + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +import axios from '@nextcloud/axios' +import { generateOcsUrl } from '@nextcloud/router' + +import type { + broadcastChatMessageParams, + broadcastChatMessageResponse, + configureBreakoutRoomsParams, + configureBreakoutRoomsResponse, + deleteBreakoutRoomsResponse, + getBreakoutRoomsParticipantsResponse, + getBreakoutRoomsResponse, + reorganizeAttendeesParams, + reorganizeAttendeesResponse, + requestAssistanceResponse, + resetRequestAssistanceResponse, + startBreakoutRoomsResponse, + stopBreakoutRoomsResponse, + switchToBreakoutRoomParams, + switchToBreakoutRoomResponse, +} from '../types' + +/** + * Create breakout rooms for a given conversation + * + * @param token The conversation token + * @param mode Either manual, auto, or free // TODO use enums + * @see CONVERSATION.BREAKOUT_ROOM_MODE + * + * @param amount The amount of breakout rooms to be created + * @param attendeeMap A JSON-encoded map of attendeeId => room number (0 based) + * (Only considered when the mode is "manual") + */ +const configureBreakoutRooms = async function(token: string, mode: 0 | 1 | 2 | 3, amount: number, attendeeMap?: string): configureBreakoutRoomsResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}', { token }), { + mode, + amount, + attendeeMap, + } as configureBreakoutRoomsParams) +} + +/** + * Apply new attendee map for breakout rooms in given conversation + * + * @param token the breakout room token + * @param attendeeMap A JSON-encoded map of attendeeId => room number (0 based) + */ +const reorganizeAttendees = async function(token: string, attendeeMap: string): reorganizeAttendeesResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/attendees', { token }), { + attendeeMap, + } as reorganizeAttendeesParams) +} + +/** + * Deletes all breakout rooms for a given conversation + * + * @param token The conversation token + */ +const deleteBreakoutRooms = async function(token: string): deleteBreakoutRoomsResponse { + return axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}', { token })) +} + +/** + * Fetches the breakout rooms for given conversation + * + * @param token The conversation token + */ +const getBreakoutRooms = async function(token: string): getBreakoutRoomsResponse { + return axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms', { token })) +} + +/** + * @param token The conversation token + */ +const startBreakoutRooms = async function(token: string): startBreakoutRoomsResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/rooms', { token })) +} + +/** + * @param token The conversation token + */ +const stopBreakoutRooms = async function(token: string): stopBreakoutRoomsResponse { + return axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/rooms', { token })) +} + +/** + * @param token the conversation token + * @param message The message to be posted + */ +const broadcastMessageToBreakoutRooms = async function(token: string, message: string): broadcastChatMessageResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/broadcast', { token }), { + message, + } as broadcastChatMessageParams) +} + +/** + * @param token the conversation token + */ +const fetchBreakoutRoomsParticipants = async function(token: string): getBreakoutRoomsParticipantsResponse { + return axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms/participants', { token })) +} + +/** + * Requests assistance from a moderator + * + * @param token the breakout room token + */ +const requestAssistance = async function(token: string): requestAssistanceResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', { token })) +} + +/** + * Resets the request assistance + * + * @param token the breakout room token + */ +const dismissRequestAssistance = async function(token: string): resetRequestAssistanceResponse { + return axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', { token })) +} + +/** + * This endpoint allows participants to switch between breakout rooms when they are allowed to choose the breakout room + * and not are automatically or manually assigned by the moderator. + * + * @param token Conversation token of the parent room hosting the breakout rooms + * @param target Conversation token of the target breakout room + */ +const switchToBreakoutRoom = async function(token: string, target: string): switchToBreakoutRoomResponse { + return axios.post(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/switch', { token }), { + target, + } as switchToBreakoutRoomParams) +} + +export { + configureBreakoutRooms, + reorganizeAttendees, + deleteBreakoutRooms, + getBreakoutRooms, + startBreakoutRooms, + stopBreakoutRooms, + broadcastMessageToBreakoutRooms, + fetchBreakoutRoomsParticipants, + requestAssistance, + dismissRequestAssistance, + switchToBreakoutRoom, +} diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index ffdb6a913e8..0aa3cc991dc 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -70,7 +70,7 @@ import { stopCallRecording, } from '../services/recordingService.js' import { talkBroadcastChannel } from '../services/talkBroadcastChannel.js' -import { useBreakoutRoomsStore } from '../stores/breakoutRooms.js' +import { useBreakoutRoomsStore } from '../stores/breakoutRooms.ts' import { useChatExtrasStore } from '../stores/chatExtras.js' import { useReactionsStore } from '../stores/reactions.js' import { useTalkHashStore } from '../stores/talkHash.js' diff --git a/src/stores/breakoutRooms.js b/src/stores/breakoutRooms.ts similarity index 71% rename from src/stores/breakoutRooms.js rename to src/stores/breakoutRooms.ts index 5d0be8b10e4..f21c4f96e83 100644 --- a/src/stores/breakoutRooms.js +++ b/src/stores/breakoutRooms.ts @@ -39,20 +39,33 @@ import { dismissRequestAssistance, reorganizeAttendees, switchToBreakoutRoom, -} from '../services/breakoutRoomsService.js' +} from '../services/breakoutRoomsService.ts' import store from '../store/index.js' +import type { + Conversation, + Participant, + BreakoutRoom, + broadcastChatMessageParams, + configureBreakoutRoomsParams, + reorganizeAttendeesParams, + switchToBreakoutRoomParams +} from '../types' +type Payload = T & { token: string } +type State = { + rooms: Record> +} export const useBreakoutRoomsStore = defineStore('breakoutRooms', { - state: () => ({ + state: (): State => ({ rooms: {}, }), getters: { - breakoutRooms: (state) => (token) => { + breakoutRooms: (state) => (token: string): BreakoutRoom[] => { return Object.values(Object(state.rooms[token])) }, - getParentRoomToken: (state) => (token) => { + getParentRoomToken: (state) => (token: string): string | undefined => { for (const parentRoomToken in state.rooms) { if (state.rooms[parentRoomToken]?.[token] !== undefined) { return parentRoomToken @@ -66,11 +79,11 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { * The breakout rooms API return an array with mixed breakout and parent rooms, we want to update * breakout rooms in this store and all conversations in conversationsStore. * - * @param {string} token the parent room token; - * @param {Array|object} conversationOrArray a single conversation or an array of conversations. + * @param token the parent room token; + * @param conversationOrArray a single conversation or an array of conversations. * */ - processConversations(token, conversationOrArray) { + processConversations(token: string, conversationOrArray: Conversation | Conversation[]) { const conversations = Array.isArray(conversationOrArray) ? conversationOrArray : [conversationOrArray] store.dispatch('patchConversations', { conversations }) }, @@ -78,9 +91,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Purges breakout rooms from both stores. * - * @param {string} token the parent room token; + * @param token the parent room token; */ - purgeBreakoutRoomsStore(token) { + purgeBreakoutRoomsStore(token: string) { for (const roomToken in this.rooms[token]) { store.dispatch('deleteConversation', roomToken) } @@ -90,10 +103,10 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Adds a breakout room to the store. * - * @param {string} token the parent room token; - * @param {object} breakoutRoom the breakout room. + * @param token the parent room token; + * @param breakoutRoom the breakout room. */ - addBreakoutRoom(token, breakoutRoom) { + addBreakoutRoom(token: string, breakoutRoom: BreakoutRoom) { if (!this.rooms[token]) { Vue.set(this.rooms, token, {}) } @@ -103,13 +116,13 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Creates breakout rooms for specified conversation. * - * @param {object} payload the action payload; - * @param {string} payload.token the parent room token; - * @param {string} payload.mode the mode of the breakout rooms; - * @param {number} payload.amount the amount of the breakout rooms to create; - * @param {string} payload.attendeeMap the stringified JSON object with attendee map. + * @param payload the action payload; + * @param payload.token the parent room token; + * @param payload.mode the mode of the breakout rooms; + * @param payload.amount the amount of the breakout rooms to create; + * @param payload.attendeeMap the stringified JSON object with attendee map. */ - async configureBreakoutRooms({ token, mode, amount, attendeeMap }) { + async configureBreakoutRooms({ token, mode, amount, attendeeMap }: Payload) { try { const response = await configureBreakoutRooms(token, mode, amount, attendeeMap) this.processConversations(token, response.data.ocs.data) @@ -118,7 +131,8 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { await this.fetchBreakoutRoomsParticipants(token) // Open the sidebar and switch to the breakout rooms tab - emit('spreed:select-active-sidebar-tab', 'breakout-rooms') + // FIXME upstream https://github.com/nextcloud-libraries/nextcloud-event-bus/pull/734 + emit('spreed:select-active-sidebar-tab', 'breakout-rooms' as unknown as object) store.dispatch('showSidebar') } catch (error) { console.error(error) @@ -129,11 +143,11 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Reassign participants to another breakout rooms. * - * @param {object} payload the action payload; - * @param {string} payload.token the parent room token; - * @param {string} payload.attendeeMap the stringified JSON object with attendee map. + * @param payload the action payload; + * @param payload.token the parent room token; + * @param payload.attendeeMap the stringified JSON object with attendee map. */ - async reorganizeAttendees({ token, attendeeMap }) { + async reorganizeAttendees({ token, attendeeMap }: Payload) { try { const response = await reorganizeAttendees(token, attendeeMap) this.processConversations(token, response.data.ocs.data) @@ -150,9 +164,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Deletes configured breakout rooms for a given parent room token. * - * @param {string} token the parent room token. + * @param token the parent room token. */ - async deleteBreakoutRooms(token) { + async deleteBreakoutRooms(token: string) { try { const response = await deleteBreakoutRooms(token) // Update returned parent conversation @@ -168,9 +182,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Get configured breakout rooms for a given parent room token. * - * @param {string} token the parent room token. + * @param token the parent room token. */ - async getBreakoutRooms(token) { + async getBreakoutRooms(token: string) { try { const response = await getBreakoutRooms(token) this.processConversations(token, response.data.ocs.data) @@ -182,9 +196,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Start a breakout rooms session for a given parent room token. * - * @param {string} token the parent room token. + * @param token the parent room token. */ - async startBreakoutRooms(token) { + async startBreakoutRooms(token: string) { try { const response = await startBreakoutRooms(token) this.processConversations(token, response.data.ocs.data) @@ -197,9 +211,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Stop a breakout rooms session for a given parent room token. * - * @param {string} token the parent room token. + * @param token the parent room token. */ - async stopBreakoutRooms(token) { + async stopBreakoutRooms(token: string) { try { const response = await stopBreakoutRooms(token) this.processConversations(token, response.data.ocs.data) @@ -212,11 +226,11 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Send a message to all breakout rooms for a given parent room token. * - * @param {object} payload the action payload; - * @param {string} payload.token the parent room token; - * @param {string} payload.message the message text. + * @param payload the action payload; + * @param payload.token the parent room token; + * @param payload.message the message text. */ - async broadcastMessageToBreakoutRooms({ token, message }) { + async broadcastMessageToBreakoutRooms({ token, message }: Payload) { try { await broadcastMessageToBreakoutRooms(token, message) } catch (error) { @@ -228,12 +242,12 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Update participants in breakout rooms for a given token. * - * @param {string} token the parent room token. + * @param token the parent room token. */ - async fetchBreakoutRoomsParticipants(token) { + async fetchBreakoutRoomsParticipants(token: string) { try { const response = await fetchBreakoutRoomsParticipants(token) - const splittedParticipants = response.data.ocs.data.reduce((acc, participant) => { + const splittedParticipants = response.data.ocs.data.reduce((acc: Record, participant) => { if (!acc[participant.roomToken]) { acc[participant.roomToken] = [] } @@ -252,9 +266,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Notify moderators when raise a hand in a breakout room with given token. * - * @param {string} token the breakout room token. + * @param token the breakout room token. */ - async requestAssistance(token) { + async requestAssistance(token: string) { try { const response = await requestAssistance(token) const parentToken = response.data.ocs.data.objectId @@ -268,9 +282,9 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Dismiss a notification about raised hand for a breakout room with given token. * - * @param {string} token the breakout room token. + * @param token the breakout room token. */ - async dismissRequestAssistance(token) { + async dismissRequestAssistance(token: string) { try { const response = await dismissRequestAssistance(token) const parentToken = response.data.ocs.data.objectId @@ -284,11 +298,11 @@ export const useBreakoutRoomsStore = defineStore('breakoutRooms', { /** * Switch between breakout rooms if participant is allowed to choose the room freely * - * @param {object} payload the action payload; - * @param {string} payload.token the parent room token; - * @param {string} payload.target the breakout room token. + * @param payload the action payload; + * @param payload.token the parent room token; + * @param payload.target the breakout room token. */ - async switchToBreakoutRoom({ token, target }) { + async switchToBreakoutRoom({ token, target }: Payload) { try { const response = await switchToBreakoutRoom(token, target) this.processConversations(token, response.data.ocs.data) diff --git a/src/types/index.ts b/src/types/index.ts index ad005697aec..02c31e34125 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -36,6 +36,9 @@ export type Notification // Conversations export type Conversation = components['schemas']['Room'] +// Participants +export type Participant = components['schemas']['Participant'] + // Chats export type Mention = RichObject<'server'|'call-type'|'icon-url'> export type File = RichObject<'size'|'path'|'link'|'mimetype'|'preview-available'> & { @@ -96,3 +99,24 @@ export type addReactionParams = ApiOptions export type deleteReactionParams = ApiOptions['params'] export type deleteReactionResponse = ApiResponse + +// Breakout rooms +export type BreakoutRoom = components['schemas']['Room'] & { + objectType: 'room', +} + +export type configureBreakoutRoomsParams = ApiOptions['params'] +export type configureBreakoutRoomsResponse = ApiResponse +export type deleteBreakoutRoomsResponse = ApiResponse +export type reorganizeAttendeesParams = ApiOptions['params'] +export type reorganizeAttendeesResponse = ApiResponse +export type getBreakoutRoomsResponse = ApiResponse +export type startBreakoutRoomsResponse = ApiResponse +export type stopBreakoutRoomsResponse = ApiResponse +export type broadcastChatMessageParams = ApiOptions['params'] +export type broadcastChatMessageResponse = ApiResponse +export type getBreakoutRoomsParticipantsResponse = ApiResponse +export type requestAssistanceResponse = ApiResponse +export type resetRequestAssistanceResponse = ApiResponse +export type switchToBreakoutRoomParams = ApiOptions['params'] +export type switchToBreakoutRoomResponse = ApiResponse