Skip to content

Commit

Permalink
refactor(pinia): refactor and rename store methods
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Mar 25, 2024
1 parent 786e04e commit fabb220
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 114 deletions.
2 changes: 1 addition & 1 deletion src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default {
methods: {
async handleCreateRooms() {
try {
await this.breakoutRoomsStore.configureBreakoutRoomsAction({
await this.breakoutRoomsStore.configureBreakoutRooms({
token: this.token,
mode: this.mode,
amount: this.amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export default {
},
createRooms() {
this.breakoutRoomsStore.configureBreakoutRoomsAction({
this.breakoutRoomsStore.configureBreakoutRooms({
token: this.token,
mode: 2,
amount: this.roomNumber,
Expand All @@ -333,7 +333,7 @@ export default {
},
reorganizeAttendees() {
this.breakoutRoomsStore.reorganizeAttendeesAction({
this.breakoutRoomsStore.reorganizeAttendees({
token: this.token,
attendeeMap: this.createAttendeeMap(),
})
Expand All @@ -345,7 +345,7 @@ export default {
},
deleteBreakoutRooms() {
this.breakoutRoomsStore.deleteBreakoutRoomsAction({ token: this.token })
this.breakoutRoomsStore.deleteBreakoutRooms(this.token)
},
},
}
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 @@ -718,7 +718,7 @@ export default {
// Broadcast message to all breakout rooms
async broadcastMessage(token, message) {
try {
await this.breakoutRoomsStore.broadcastMessageToBreakoutRoomsAction({ token, message })
await this.breakoutRoomsStore.broadcastMessageToBreakoutRooms({ token, message })
this.$emit('sent')
} catch {
this.$emit('failure')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default {
},
dismissRequestAssistance() {
this.breakoutRoomsStore.resetRequestAssistanceAction({ token: this.roomToken })
this.breakoutRoomsStore.dismissRequestAssistance(this.roomToken)
},
async joinRoom() {
Expand All @@ -235,7 +235,7 @@ export default {
} else {
try {
if (this.mainConversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE) {
await this.breakoutRoomsStore.switchToBreakoutRoomAction({
await this.breakoutRoomsStore.switchToBreakoutRoom({
token: this.breakoutRoomsStore.getParentRoomToken(this.roomToken),
target: this.roomToken,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ export default {
methods: {
startBreakoutRooms() {
this.breakoutRoomsStore.startBreakoutRoomsAction(this.mainToken)
this.breakoutRoomsStore.startBreakoutRooms(this.mainToken)
},
stopBreakoutRooms() {
this.breakoutRoomsStore.stopBreakoutRoomsAction(this.mainToken)
this.breakoutRoomsStore.stopBreakoutRooms(this.mainToken)
},
openSendMessageDialog() {
Expand Down
16 changes: 4 additions & 12 deletions src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export default {
mounted() {
// Get the breakout room every time the tab is mounted
this.getBreakoutRooms()
if (this.breakoutRoomsConfigured) {
this.breakoutRoomsStore.getBreakoutRooms(this.mainToken)
}
},
beforeDestroy() {
Expand All @@ -155,19 +157,9 @@ export default {
},
methods: {
getBreakoutRooms() {
if (this.breakoutRoomsConfigured) {
this.breakoutRoomsStore.getBreakoutRoomsAction({
token: this.mainToken,
})
}
},
getParticipants() {
if (this.breakoutRoomsConfigured) {
this.breakoutRoomsStore.getBreakoutRoomsParticipantsAction({
token: this.mainToken,
})
this.breakoutRoomsStore.fetchBreakoutRoomsParticipants(this.mainToken)
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ export default {
}
const hasAssistanceRequested = this.conversation.breakoutRoomStatus === CONVERSATION.BREAKOUT_ROOM_STATUS.STATUS_ASSISTANCE_REQUESTED
if (newState && !hasAssistanceRequested) {
this.breakoutRoomsStore.requestAssistanceAction({ token: this.token })
this.breakoutRoomsStore.requestAssistance(this.token)
} else if (!newState && hasAssistanceRequested) {
this.breakoutRoomsStore.resetRequestAssistanceAction({ token: this.token })
this.breakoutRoomsStore.dismissRequestAssistance(this.token)
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions src/services/breakoutRoomsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const broadcastMessageToBreakoutRooms = async function(token, message) {
* @param {string} token the conversation token
* @return {Promise<import('axios').AxiosResponse<any>>} The array of conversations
*/
const getBreakoutRoomsParticipants = async function(token) {
const fetchBreakoutRoomsParticipants = async function(token) {
return await axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms/participants', {
token,
}))
Expand All @@ -139,7 +139,7 @@ const requestAssistance = async function(token) {
* @param {string} token the breakout room token
* @return {Promise<import('axios').AxiosResponse<any>>} The array of conversations
*/
const resetRequestAssistance = async function(token) {
const dismissRequestAssistance = async function(token) {
return await axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', {
token,
})
Expand Down Expand Up @@ -171,8 +171,8 @@ export {
startBreakoutRooms,
stopBreakoutRooms,
broadcastMessageToBreakoutRooms,
getBreakoutRoomsParticipants,
fetchBreakoutRoomsParticipants,
requestAssistance,
resetRequestAssistance,
dismissRequestAssistance,
switchToBreakoutRoom,
}
5 changes: 1 addition & 4 deletions src/store/conversationsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,7 @@ const actions = {
}

if (newConversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM) {
breakoutRoomsStore.addBreakoutRoom({
parentRoomToken: newConversation.objectId,
breakoutRoom: newConversation,
})
breakoutRoomsStore.addBreakoutRoom(newConversation.objectId, newConversation)
}
}

Expand Down
Loading

0 comments on commit fabb220

Please sign in to comment.