Skip to content

Commit

Permalink
refactor(pinia): migrate breakoutRoomsStore to Pinia
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Mar 22, 2024
1 parent efafb6e commit 786e04e
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 302 deletions.
10 changes: 9 additions & 1 deletion src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import BreakoutRoomsParticipantsEditor from './BreakoutRoomsParticipantsEditor.vue'
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
export default {
name: 'BreakoutRoomsEditor',
Expand All @@ -117,6 +119,12 @@ export default {
emits: ['close'],
setup() {
return {
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
return {
mode: '1',
Expand Down Expand Up @@ -148,7 +156,7 @@ export default {
methods: {
async handleCreateRooms() {
try {
await this.$store.dispatch('configureBreakoutRoomsAction', {
await this.breakoutRoomsStore.configureBreakoutRoomsAction({
token: this.token,
mode: this.mode,
amount: this.amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +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'
export default {
name: 'BreakoutRoomsParticipantsEditor',
Expand Down Expand Up @@ -149,12 +150,18 @@ export default {
breakoutRooms: {
type: Array,
default: undefined,
default: () => [],
},
},
emits: ['back', 'close'],
setup() {
return {
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
return {
selectedParticipants: [],
Expand Down Expand Up @@ -207,7 +214,7 @@ export default {
// If the breakoutRooms prop is populated it means that this component is
// being used to reorganize the attendees of an existing breakout room.
isReorganizingAttendees() {
return this.breakoutRooms?.length
return this.breakoutRooms.length
},
confirmButtonLabel() {
Expand Down Expand Up @@ -316,7 +323,7 @@ export default {
},
createRooms() {
this.$store.dispatch('configureBreakoutRoomsAction', {
this.breakoutRoomsStore.configureBreakoutRoomsAction({
token: this.token,
mode: 2,
amount: this.roomNumber,
Expand All @@ -326,7 +333,7 @@ export default {
},
reorganizeAttendees() {
this.$store.dispatch('reorganizeAttendeesAction', {
this.breakoutRoomsStore.reorganizeAttendeesAction({
token: this.token,
attendeeMap: this.createAttendeeMap(),
})
Expand All @@ -338,9 +345,7 @@ export default {
},
deleteBreakoutRooms() {
this.$store.dispatch('deleteBreakoutRoomsAction', {
token: this.token,
})
this.breakoutRoomsStore.deleteBreakoutRoomsAction({ token: this.token })
},
},
}
Expand Down
11 changes: 5 additions & 6 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +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 { useChatExtrasStore } from '../../stores/chatExtras.js'
import { useSettingsStore } from '../../stores/settings.js'
import { fetchClipboardContent } from '../../utils/clipboard.js'
Expand Down Expand Up @@ -314,12 +315,10 @@ export default {
expose: ['focusInput'],
setup() {
const chatExtrasStore = useChatExtrasStore()
const settingsStore = useSettingsStore()
return {
chatExtrasStore,
settingsStore,
breakoutRoomsStore: useBreakoutRoomsStore(),
chatExtrasStore: useChatExtrasStore(),
settingsStore: useSettingsStore(),
supportTypingStatus,
}
},
Expand Down Expand Up @@ -719,7 +718,7 @@ export default {
// Broadcast message to all breakout rooms
async broadcastMessage(token, message) {
try {
await this.$store.dispatch('broadcastMessageToBreakoutRoomsAction', { token, message })
await this.breakoutRoomsStore.broadcastMessageToBreakoutRoomsAction({ token, message })
this.$emit('sent')
} catch {
this.$emit('failure')
Expand Down
13 changes: 10 additions & 3 deletions src/components/RightSidebar/BreakoutRooms/BreakoutRoomItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +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'
export default {
name: 'BreakoutRoomItem',
Expand Down Expand Up @@ -138,6 +139,12 @@ export default {
},
},
setup() {
return {
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
return {
showParticipants: true,
Expand Down Expand Up @@ -217,7 +224,7 @@ export default {
},
dismissRequestAssistance() {
this.$store.dispatch('resetRequestAssistanceAction', { token: this.roomToken })
this.breakoutRoomsStore.resetRequestAssistanceAction({ token: this.roomToken })
},
async joinRoom() {
Expand All @@ -228,8 +235,8 @@ export default {
} else {
try {
if (this.mainConversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE) {
await this.$store.dispatch('switchToBreakoutRoomAction', {
token: this.$store.getters.parentRoomToken(this.roomToken),
await this.breakoutRoomsStore.switchToBreakoutRoomAction({
token: this.breakoutRoomsStore.getParentRoomToken(this.roomToken),
target: this.roomToken,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +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'
export default {
name: 'BreakoutRoomsActions',
Expand Down Expand Up @@ -169,8 +170,10 @@ export default {
},
setup() {
const isInCall = useIsInCall()
return { isInCall }
return {
isInCall: useIsInCall(),
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
Expand Down Expand Up @@ -235,11 +238,11 @@ export default {
methods: {
startBreakoutRooms() {
this.$store.dispatch('startBreakoutRoomsAction', this.mainToken)
this.breakoutRoomsStore.startBreakoutRoomsAction(this.mainToken)
},
stopBreakoutRooms() {
this.$store.dispatch('stopBreakoutRoomsAction', this.mainToken)
this.breakoutRoomsStore.stopBreakoutRoomsAction(this.mainToken)
},
openSendMessageDialog() {
Expand Down
13 changes: 10 additions & 3 deletions src/components/RightSidebar/BreakoutRooms/BreakoutRoomsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +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'
export default {
name: 'BreakoutRoomsTab',
Expand Down Expand Up @@ -90,6 +91,12 @@ export default {
},
},
setup() {
return {
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
return {
breakoutRoomsParticipantsInterval: undefined,
Expand All @@ -111,7 +118,7 @@ export default {
},
breakoutRooms() {
return this.$store.getters.breakoutRooms(this.mainToken)
return this.breakoutRoomsStore.breakoutRooms(this.mainToken)
},
breakoutRoomsConfigured() {
Expand Down Expand Up @@ -150,15 +157,15 @@ export default {
methods: {
getBreakoutRooms() {
if (this.breakoutRoomsConfigured) {
this.$store.dispatch('getBreakoutRoomsAction', {
this.breakoutRoomsStore.getBreakoutRoomsAction({
token: this.mainToken,
})
}
},
getParticipants() {
if (this.breakoutRoomsConfigured) {
this.$store.dispatch('getBreakoutRoomsParticipantsAction', {
this.breakoutRoomsStore.getBreakoutRoomsParticipantsAction({
token: this.mainToken,
})
}
Expand Down
14 changes: 6 additions & 8 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +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 { useSettingsStore } from '../../stores/settings.js'
import { useTalkHashStore } from '../../stores/talkHash.js'
import { blockCalls, unsupportedWarning } from '../../utils/browserCheck.js'
Expand Down Expand Up @@ -184,13 +185,11 @@ export default {
},
setup() {
const isInCall = useIsInCall()
const talkHashStore = useTalkHashStore()
const settingsStore = useSettingsStore()
return {
isInCall,
settingsStore,
talkHashStore,
isInCall: useIsInCall(),
breakoutRoomsStore: useBreakoutRoomsStore(),
talkHashStore: useTalkHashStore(),
settingsStore: useSettingsStore(),
}
},
Expand Down Expand Up @@ -430,9 +429,8 @@ export default {
},
async switchToParentRoom() {
const parentRoomToken = this.$store.getters.parentRoomToken(this.token)
EventBus.$emit('switch-to-conversation', {
token: parentRoomToken,
token: this.breakoutRoomsStore.getParentRoomToken(this.token),
})
},
Expand Down
11 changes: 7 additions & 4 deletions src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ import PromotedView from '../../assets/missingMaterialDesignIcons/PromotedView.v
import { useIsInCall } from '../../composables/useIsInCall.js'
import { CALL, CONVERSATION, PARTICIPANT } from '../../constants.js'
import { generateAbsoluteUrl } from '../../utils/handleUrl.ts'
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.js'
import { callParticipantCollection } from '../../utils/webrtc/index.js'
export default {
Expand Down Expand Up @@ -252,8 +253,10 @@ export default {
emits: ['open-breakout-rooms-editor'],
setup() {
const isInCall = useIsInCall()
return { isInCall }
return {
isInCall: useIsInCall(),
breakoutRoomsStore: useBreakoutRoomsStore(),
}
},
data() {
Expand Down Expand Up @@ -475,9 +478,9 @@ export default {
}
const hasAssistanceRequested = this.conversation.breakoutRoomStatus === CONVERSATION.BREAKOUT_ROOM_STATUS.STATUS_ASSISTANCE_REQUESTED
if (newState && !hasAssistanceRequested) {
this.$store.dispatch('requestAssistanceAction', { token: this.token })
this.breakoutRoomsStore.requestAssistanceAction({ token: this.token })
} else if (!newState && hasAssistanceRequested) {
this.$store.dispatch('resetRequestAssistanceAction', { token: this.token })
this.breakoutRoomsStore.resetRequestAssistanceAction({ token: this.token })
}
}
},
Expand Down
Loading

0 comments on commit 786e04e

Please sign in to comment.