Skip to content

Commit 38a03ec

Browse files
authored
Merge pull request #11649 from nextcloud/refactor/noid/migrate-breakout-store
refactor(pinia): migrate breakoutRoomsStore to Pinia 🍍
2 parents 09fadad + 0b7330a commit 38a03ec

File tree

13 files changed

+376
-319
lines changed

13 files changed

+376
-319
lines changed

src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
9797
9898
import BreakoutRoomsParticipantsEditor from './BreakoutRoomsParticipantsEditor.vue'
9999
100+
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
101+
100102
export default {
101103
name: 'BreakoutRoomsEditor',
102104
@@ -117,6 +119,12 @@ export default {
117119
118120
emits: ['close'],
119121
122+
setup() {
123+
return {
124+
breakoutRoomsStore: useBreakoutRoomsStore(),
125+
}
126+
},
127+
120128
data() {
121129
return {
122130
mode: '1',
@@ -148,7 +156,7 @@ export default {
148156
methods: {
149157
async handleCreateRooms() {
150158
try {
151-
await this.$store.dispatch('configureBreakoutRoomsAction', {
159+
await this.breakoutRoomsStore.configureBreakoutRooms({
152160
token: this.token,
153161
mode: this.mode,
154162
amount: this.amount,

src/components/BreakoutRoomsEditor/BreakoutRoomsParticipantsEditor.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import SelectableParticipant from './SelectableParticipant.vue'
119119
import BreakoutRoomItem from '../RightSidebar/BreakoutRooms/BreakoutRoomItem.vue'
120120
121121
import { ATTENDEE, CONVERSATION, PARTICIPANT } from '../../constants.js'
122+
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
122123
123124
export default {
124125
name: 'BreakoutRoomsParticipantsEditor',
@@ -149,12 +150,18 @@ export default {
149150
150151
breakoutRooms: {
151152
type: Array,
152-
default: undefined,
153+
default: () => [],
153154
},
154155
},
155156
156157
emits: ['back', 'close'],
157158
159+
setup() {
160+
return {
161+
breakoutRoomsStore: useBreakoutRoomsStore(),
162+
}
163+
},
164+
158165
data() {
159166
return {
160167
selectedParticipants: [],
@@ -207,7 +214,7 @@ export default {
207214
// If the breakoutRooms prop is populated it means that this component is
208215
// being used to reorganize the attendees of an existing breakout room.
209216
isReorganizingAttendees() {
210-
return this.breakoutRooms?.length
217+
return this.breakoutRooms.length
211218
},
212219
213220
confirmButtonLabel() {
@@ -316,7 +323,7 @@ export default {
316323
},
317324
318325
createRooms() {
319-
this.$store.dispatch('configureBreakoutRoomsAction', {
326+
this.breakoutRoomsStore.configureBreakoutRooms({
320327
token: this.token,
321328
mode: 2,
322329
amount: this.roomNumber,
@@ -326,7 +333,7 @@ export default {
326333
},
327334
328335
reorganizeAttendees() {
329-
this.$store.dispatch('reorganizeAttendeesAction', {
336+
this.breakoutRoomsStore.reorganizeAttendees({
330337
token: this.token,
331338
attendeeMap: this.createAttendeeMap(),
332339
})
@@ -338,9 +345,7 @@ export default {
338345
},
339346
340347
deleteBreakoutRooms() {
341-
this.$store.dispatch('deleteBreakoutRoomsAction', {
342-
token: this.token,
343-
})
348+
this.breakoutRoomsStore.deleteBreakoutRooms(this.token)
344349
},
345350
},
346351
}

src/components/NewMessage/NewMessage.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ import BrowserStorage from '../../services/BrowserStorage.js'
224224
import { EventBus } from '../../services/EventBus.js'
225225
import { shareFile } from '../../services/filesSharingServices.js'
226226
import { searchPossibleMentions } from '../../services/mentionsService.js'
227+
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
227228
import { useChatExtrasStore } from '../../stores/chatExtras.js'
228229
import { useSettingsStore } from '../../stores/settings.js'
229230
import { fetchClipboardContent } from '../../utils/clipboard.js'
@@ -314,12 +315,10 @@ export default {
314315
expose: ['focusInput'],
315316
316317
setup() {
317-
const chatExtrasStore = useChatExtrasStore()
318-
const settingsStore = useSettingsStore()
319-
320318
return {
321-
chatExtrasStore,
322-
settingsStore,
319+
breakoutRoomsStore: useBreakoutRoomsStore(),
320+
chatExtrasStore: useChatExtrasStore(),
321+
settingsStore: useSettingsStore(),
323322
supportTypingStatus,
324323
}
325324
},
@@ -719,7 +718,7 @@ export default {
719718
// Broadcast message to all breakout rooms
720719
async broadcastMessage(token, message) {
721720
try {
722-
await this.$store.dispatch('broadcastMessageToBreakoutRoomsAction', { token, message })
721+
await this.breakoutRoomsStore.broadcastMessageToBreakoutRooms({ token, message })
723722
this.$emit('sent')
724723
} catch {
725724
this.$emit('failure')

src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import SendMessageDialog from '../../BreakoutRoomsEditor/SendMessageDialog.vue'
9393
9494
import { CONVERSATION, PARTICIPANT } from '../../../constants.js'
9595
import { EventBus } from '../../../services/EventBus.js'
96+
import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js'
9697
9798
export default {
9899
name: 'BreakoutRoomItem',
@@ -138,6 +139,12 @@ export default {
138139
},
139140
},
140141
142+
setup() {
143+
return {
144+
breakoutRoomsStore: useBreakoutRoomsStore(),
145+
}
146+
},
147+
141148
data() {
142149
return {
143150
showParticipants: true,
@@ -217,7 +224,7 @@ export default {
217224
},
218225
219226
dismissRequestAssistance() {
220-
this.$store.dispatch('resetRequestAssistanceAction', { token: this.roomToken })
227+
this.breakoutRoomsStore.dismissRequestAssistance(this.roomToken)
221228
},
222229
223230
async joinRoom() {
@@ -228,8 +235,8 @@ export default {
228235
} else {
229236
try {
230237
if (this.mainConversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE) {
231-
await this.$store.dispatch('switchToBreakoutRoomAction', {
232-
token: this.$store.getters.parentRoomToken(this.roomToken),
238+
await this.breakoutRoomsStore.switchToBreakoutRoom({
239+
token: this.breakoutRoomsStore.getParentRoomToken(this.roomToken),
233240
target: this.roomToken,
234241
})
235242
}

src/components/RightSidebar/BreakoutRooms/BreakoutRoomsActions.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ import SendMessageDialog from '../../BreakoutRoomsEditor/SendMessageDialog.vue'
124124
import { useIsInCall } from '../../../composables/useIsInCall.js'
125125
import { CONVERSATION, PARTICIPANT } from '../../../constants.js'
126126
import { EventBus } from '../../../services/EventBus.js'
127+
import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js'
127128
128129
export default {
129130
name: 'BreakoutRoomsActions',
@@ -169,8 +170,10 @@ export default {
169170
},
170171
171172
setup() {
172-
const isInCall = useIsInCall()
173-
return { isInCall }
173+
return {
174+
isInCall: useIsInCall(),
175+
breakoutRoomsStore: useBreakoutRoomsStore(),
176+
}
174177
},
175178
176179
data() {
@@ -235,11 +238,11 @@ export default {
235238
236239
methods: {
237240
startBreakoutRooms() {
238-
this.$store.dispatch('startBreakoutRoomsAction', this.mainToken)
241+
this.breakoutRoomsStore.startBreakoutRooms(this.mainToken)
239242
},
240243
241244
stopBreakoutRooms() {
242-
this.$store.dispatch('stopBreakoutRoomsAction', this.mainToken)
245+
this.breakoutRoomsStore.stopBreakoutRooms(this.mainToken)
243246
},
244247
245248
openSendMessageDialog() {

src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import BreakoutRoomsActions from './BreakoutRoomsActions.vue'
5858
import Participant from '../Participants/Participant.vue'
5959
6060
import { CONVERSATION, PARTICIPANT } from '../../../constants.js'
61+
import { useBreakoutRoomsStore } from '../../../stores/breakoutRooms.js'
6162
6263
export default {
6364
name: 'BreakoutRoomsTab',
@@ -90,6 +91,12 @@ export default {
9091
},
9192
},
9293
94+
setup() {
95+
return {
96+
breakoutRoomsStore: useBreakoutRoomsStore(),
97+
}
98+
},
99+
93100
data() {
94101
return {
95102
breakoutRoomsParticipantsInterval: undefined,
@@ -111,7 +118,7 @@ export default {
111118
},
112119
113120
breakoutRooms() {
114-
return this.$store.getters.breakoutRooms(this.mainToken)
121+
return this.breakoutRoomsStore.breakoutRooms(this.mainToken)
115122
},
116123
117124
breakoutRoomsConfigured() {
@@ -139,7 +146,9 @@ export default {
139146
140147
mounted() {
141148
// Get the breakout room every time the tab is mounted
142-
this.getBreakoutRooms()
149+
if (this.breakoutRoomsConfigured) {
150+
this.breakoutRoomsStore.getBreakoutRooms(this.mainToken)
151+
}
143152
},
144153
145154
beforeDestroy() {
@@ -148,19 +157,9 @@ export default {
148157
},
149158
150159
methods: {
151-
getBreakoutRooms() {
152-
if (this.breakoutRoomsConfigured) {
153-
this.$store.dispatch('getBreakoutRoomsAction', {
154-
token: this.mainToken,
155-
})
156-
}
157-
},
158-
159160
getParticipants() {
160161
if (this.breakoutRoomsConfigured) {
161-
this.$store.dispatch('getBreakoutRoomsParticipantsAction', {
162-
token: this.mainToken,
163-
})
162+
this.breakoutRoomsStore.fetchBreakoutRoomsParticipants(this.mainToken)
164163
}
165164
},
166165
},

src/components/TopBar/CallButton.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ import { useIsInCall } from '../../composables/useIsInCall.js'
116116
import { ATTENDEE, CALL, CONVERSATION, PARTICIPANT } from '../../constants.js'
117117
import { callSIPDialOut } from '../../services/callsService.js'
118118
import { EventBus } from '../../services/EventBus.js'
119+
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
119120
import { useSettingsStore } from '../../stores/settings.js'
120121
import { useTalkHashStore } from '../../stores/talkHash.js'
121122
import { blockCalls, unsupportedWarning } from '../../utils/browserCheck.js'
@@ -184,13 +185,11 @@ export default {
184185
},
185186
186187
setup() {
187-
const isInCall = useIsInCall()
188-
const talkHashStore = useTalkHashStore()
189-
const settingsStore = useSettingsStore()
190188
return {
191-
isInCall,
192-
settingsStore,
193-
talkHashStore,
189+
isInCall: useIsInCall(),
190+
breakoutRoomsStore: useBreakoutRoomsStore(),
191+
talkHashStore: useTalkHashStore(),
192+
settingsStore: useSettingsStore(),
194193
}
195194
},
196195
@@ -430,9 +429,8 @@ export default {
430429
},
431430
432431
async switchToParentRoom() {
433-
const parentRoomToken = this.$store.getters.parentRoomToken(this.token)
434432
EventBus.$emit('switch-to-conversation', {
435-
token: parentRoomToken,
433+
token: this.breakoutRoomsStore.getParentRoomToken(this.token),
436434
})
437435
},
438436

src/components/TopBar/TopBarMenu.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ import PromotedView from '../../assets/missingMaterialDesignIcons/PromotedView.v
190190
191191
import { useIsInCall } from '../../composables/useIsInCall.js'
192192
import { CALL, CONVERSATION, PARTICIPANT } from '../../constants.js'
193+
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
193194
import { generateAbsoluteUrl } from '../../utils/handleUrl.ts'
194195
import { callParticipantCollection } from '../../utils/webrtc/index.js'
195196
@@ -252,8 +253,10 @@ export default {
252253
emits: ['open-breakout-rooms-editor'],
253254
254255
setup() {
255-
const isInCall = useIsInCall()
256-
return { isInCall }
256+
return {
257+
isInCall: useIsInCall(),
258+
breakoutRoomsStore: useBreakoutRoomsStore(),
259+
}
257260
},
258261
259262
data() {
@@ -475,9 +478,9 @@ export default {
475478
}
476479
const hasAssistanceRequested = this.conversation.breakoutRoomStatus === CONVERSATION.BREAKOUT_ROOM_STATUS.STATUS_ASSISTANCE_REQUESTED
477480
if (newState && !hasAssistanceRequested) {
478-
this.$store.dispatch('requestAssistanceAction', { token: this.token })
481+
this.breakoutRoomsStore.requestAssistance(this.token)
479482
} else if (!newState && hasAssistanceRequested) {
480-
this.$store.dispatch('resetRequestAssistanceAction', { token: this.token })
483+
this.breakoutRoomsStore.dismissRequestAssistance(this.token)
481484
}
482485
}
483486
},

src/services/breakoutRoomsService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const broadcastMessageToBreakoutRooms = async function(token, message) {
114114
* @param {string} token the conversation token
115115
* @return {Promise<import('axios').AxiosResponse<any>>} The array of conversations
116116
*/
117-
const getBreakoutRoomsParticipants = async function(token) {
117+
const fetchBreakoutRoomsParticipants = async function(token) {
118118
return await axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}/breakout-rooms/participants', {
119119
token,
120120
}))
@@ -139,7 +139,7 @@ const requestAssistance = async function(token) {
139139
* @param {string} token the breakout room token
140140
* @return {Promise<import('axios').AxiosResponse<any>>} The array of conversations
141141
*/
142-
const resetRequestAssistance = async function(token) {
142+
const dismissRequestAssistance = async function(token) {
143143
return await axios.delete(generateOcsUrl('/apps/spreed/api/v1/breakout-rooms/{token}/request-assistance', {
144144
token,
145145
})
@@ -171,8 +171,8 @@ export {
171171
startBreakoutRooms,
172172
stopBreakoutRooms,
173173
broadcastMessageToBreakoutRooms,
174-
getBreakoutRoomsParticipants,
174+
fetchBreakoutRoomsParticipants,
175175
requestAssistance,
176-
resetRequestAssistance,
176+
dismissRequestAssistance,
177177
switchToBreakoutRoom,
178178
}

0 commit comments

Comments
 (0)