Skip to content

Commit

Permalink
WIP: distinguish the 2 phases of joining the call: connect to the cal…
Browse files Browse the repository at this point in the history
…l AND wait for participants list

Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Oct 21, 2024
1 parent e707c4e commit 0d90b15
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 9 deletions.
18 changes: 16 additions & 2 deletions src/components/CallView/shared/EmptyCallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import IconPhone from 'vue-material-design-icons/Phone.vue'
import { t } from '@nextcloud/l10n'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'

import { CONVERSATION, PARTICIPANT } from '../../../constants.js'
import { copyConversationLinkToClipboard } from '../../../utils/handleUrl.ts'
Expand All @@ -43,6 +44,7 @@ export default {

components: {
NcButton,
NcLoadingIcon,
IconAccountMultiple,
IconLinkVariant,
IconPhone,
Expand All @@ -66,11 +68,14 @@ export default {
},

computed: {

token() {
return this.$store.getters.getToken()
},

isConnecting() {
return this.$store.getters.isConnecting(this.token)
},

conversation() {
return this.$store.getters.conversation(this.token)
},
Expand Down Expand Up @@ -116,14 +121,19 @@ export default {
},

emptyCallViewIcon() {
if (this.isPhoneConversation) {
if (this.isConnecting) {
return NcLoadingIcon
} else if (this.isPhoneConversation) {
return IconPhone
} else {
return this.isPublicConversation ? IconLinkVariant : IconAccountMultiple
}
},

title() {
if (this.isConnecting) {
return t('spreed', 'Connecting …')
}
if (this.isPhoneConversation) {
return t('spreed', 'Calling …')
}
Expand All @@ -134,6 +144,10 @@ export default {
},

message() {
if (this.isConnecting) {
return ''
}

if (this.isPasswordRequestConversation || this.isFileConversation) {
return ''
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
id="call_button"
:title="startCallTitle"
:aria-label="startCallLabel"
:disabled="startCallButtonDisabled || loading || isConnecting"
:disabled="startCallButtonDisabled || loading || isJoiningCall"
:type="startCallButtonType"
@click="handleClick">
<template #icon>
<NcLoadingIcon v-if="isConnecting || loading" />
<NcLoadingIcon v-if="isJoiningCall || loading" />
<IconPhoneDial v-else-if="isPhoneRoom" :size="20" />
<IconPhoneOutline v-else-if="silentCall" :size="20" />
<IconPhone v-else :size="20" />
Expand Down Expand Up @@ -274,7 +274,7 @@ export default {
return t('spreed', 'Join call')
}

if (this.isConnecting) {
if (this.isJoiningCall) {
return t('spreed', 'Connecting...')
}

Expand Down Expand Up @@ -345,8 +345,8 @@ export default {
return this.$store.getters.isInLobby
},

isConnecting() {
return this.$store.getters.isConnecting(this.token)
isJoiningCall() {
return this.$store.getters.isJoiningCall(this.token)
},

connectionFailed() {
Expand Down
46 changes: 44 additions & 2 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const state = {
},
inCall: {
},
joiningCall: {
},
connecting: {
},
connectionFailed: {
Expand All @@ -89,6 +91,10 @@ const getters = {
return !!(state.inCall[token] && Object.keys(state.inCall[token]).length > 0)
},

isJoiningCall: (state) => (token) => {
return !!(state.joiningCall[token] && Object.keys(state.joiningCall[token]).length > 0)
},

isConnecting: (state) => (token) => {
return !!(state.connecting[token] && Object.keys(state.connecting[token]).length > 0)
},
Expand Down Expand Up @@ -337,6 +343,19 @@ const mutations = {
Vue.delete(state.connectionFailed, token)
},

joiningCall(state, { token, sessionId, flags }) {
if (!state.joiningCall[token]) {
Vue.set(state.joiningCall, token, {})
}
Vue.set(state.joiningCall[token], sessionId, flags)
},

finishedJoiningCall(state, { token, sessionId }) {
if (state.joiningCall[token] && state.joiningCall[token][sessionId]) {
Vue.delete(state.joiningCall[token], sessionId)
}
},

connecting(state, { token, sessionId, flags }) {
if (!state.connecting[token]) {
Vue.set(state.connecting, token, {})
Expand Down Expand Up @@ -780,7 +799,12 @@ const actions = {
},

async joinCall({ commit, getters }, { token, participantIdentifier, flags, silent, recordingConsent }) {
commit('connecting', { token, sessionId: participantIdentifier.sessionId, flags })
// t0: press join -> joinining call : true
// t1: signaling-join-call received -> joinining : false, inCall : true, connecting: true
// t1': signaling-join-call-failed received -> joinining : false, inCall: false, connecting: false
// t2: signaling-users-in-room (internal signaling) OR signaling-participant-list-changed (external signaling) -> connecting: false

commit('joiningCall', { token, sessionId: participantIdentifier.sessionId, flags })

if (!participantIdentifier?.sessionId) {
console.error('Trying to join call without sessionId')
Expand All @@ -800,14 +824,32 @@ const actions = {
sessionId: participantIdentifier.sessionId,
flags,
})
commit('finishedConnecting', { token, sessionId: participantIdentifier.sessionId })
commit('finishedJoiningCall', { token, sessionId: participantIdentifier.sessionId })
// Set connecting until participants list is received
commit('connecting', { token, sessionId: participantIdentifier.sessionId, flags })
})

// Preparing the event listener for the signaling-join-call-failed event
EventBus.once('signaling-join-call-failed', () => {
commit('finishedJoiningCall', { token, sessionId: participantIdentifier.sessionId })
})

// Internal signaling event
EventBus.once('signaling-users-in-room', () => {
commit('finishedConnecting', { token, sessionId: participantIdentifier.sessionId })
})

// External signaling event
// FIXME: This is a workaround for the missing signaling event
EventBus.once('signaling-participant-list-changed', () => {
commit('finishedConnecting', { token, sessionId: participantIdentifier.sessionId })
})
setTimeout(() => {
// If by accident we never receive a users list, just switch to
// "Waiting for others to join the call …" after some seconds.
commit('finishedConnecting', { token, sessionId: participantIdentifier.sessionId })
}, 10000)

try {
const actualFlags = await joinCall(token, flags, silent, recordingConsent)
const updatedData = {
Expand Down

0 comments on commit 0d90b15

Please sign in to comment.