Skip to content

Commit

Permalink
Merge pull request #11894 from nextcloud/refactor/noid/breakout-to-ty…
Browse files Browse the repository at this point in the history
…pescript

refactor(breakoutRooms): migrate service to typescript
  • Loading branch information
Antreesy authored Mar 28, 2024
2 parents 637b9eb + cd8949c commit 5f8eeac
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 233 deletions.
2 changes: 1 addition & 1 deletion src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
178 changes: 0 additions & 178 deletions src/services/breakoutRoomsService.js
Original file line number Diff line number Diff line change
@@ -1,178 +0,0 @@
/**
* @copyright Copyright (c) 2022 Marco Ambrosini <marcoambrosini@pm.me>
*
* @author Marco Ambrosini <marcoambrosini@pm.me>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
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<import('axios').AxiosResponse<any>>}
*/
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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>}
*/
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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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<import('axios').AxiosResponse<any>>} 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,
}
Loading

0 comments on commit 5f8eeac

Please sign in to comment.