Skip to content

Commit

Permalink
fix: pass actual flags
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad authored and backportbot[bot] committed Nov 8, 2024
1 parent 39f5e5d commit 085aca1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
49 changes: 23 additions & 26 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ const mutations = {
},

setInCall(state, { token, sessionId, flags }) {
if (state.connectionFailed[token]) {
Vue.delete(state.connectionFailed, token)
}
if (flags === PARTICIPANT.CALL_FLAG.DISCONNECTED) {
if (state.inCall[token] && state.inCall[token][sessionId]) {
Vue.delete(state.inCall[token], sessionId)
Expand Down Expand Up @@ -850,7 +847,7 @@ const actions = {
// Exception 2: We may receive the users list in a second event of signaling-users-changed or signaling-users-in-room
// In this case, we always check if the list is the updated one (it has the current participant in the call)

const { sessionId } = participantIdentifier
const { sessionId } = participantIdentifier ?? {}

if (!sessionId) {
console.error('Trying to join call without sessionId')
Expand All @@ -863,17 +860,23 @@ const actions = {
return
}

let isParticipantsListReceived = null
let isParticipantsListReceived = false
let connectingTimeout = null
commit('joiningCall', { token, sessionId, flags })

const handleJoinCall = () => {
const handleJoinCall = ([token, flags]) => {
commit('setInCall', { token, sessionId, flags })
commit('finishedJoiningCall', { token, sessionId })

if (isParticipantsListReceived) {
finishConnecting()
} else {
commit('connecting', { token, sessionId, flags })
// Fallback in case we never receive the users list after joining the call
connectingTimeout = setTimeout(() => {
// If, by accident, we never receive a users list, just switch to
// "Waiting for others to join the call …" after some seconds.
finishConnecting()
}, 10000)
}
}

Expand All @@ -883,10 +886,15 @@ const actions = {
token,
payload
})
commit('setInCall', {
token,
sessionId: participantIdentifier.sessionId,
flags: PARTICIPANT.CALL_FLAG.DISCONNECTED,
})
}

const handleUsersInRoom = (payload) => {
const participant = payload[0].find(p => p.sessionId === sessionId)
const handleParticipantsListReceived = (payload, key) => {
const participant = payload[0].find(p => p[key] === sessionId)
if (participant && participant.inCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED) {
if (state.joiningCall[token]?.[sessionId]) {
isParticipantsListReceived = true
Expand All @@ -897,35 +905,24 @@ const actions = {
}
}

const handleUsersInRoom = (payload) => {
handleParticipantsListReceived(payload, 'sessionId')
}

const handleUsersChanged = (payload) => {
const participant = payload[0].find(p => p.nextcloudSessionId === sessionId)
if (participant && participant.inCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED) {
if (state.joiningCall[token]?.[sessionId]) {
isParticipantsListReceived = true
commit('connecting', { token, sessionId, flags })
return
}
finishConnecting()
}
handleParticipantsListReceived(payload, 'nextcloudSessionId')
}

const finishConnecting = () => {
isParticipantsListReceived = null
commit('finishedConnecting', { token, sessionId })
commit('finishedJoiningCall', { token, sessionId })
EventBus.off('signaling-join-call', handleJoinCall)
EventBus.off('signaling-join-call-failed', handleJoinCallFailed)
EventBus.off('signaling-users-in-room', handleUsersInRoom)
EventBus.off('signaling-users-changed', handleUsersChanged)
clearTimeout(connectingTimeout)
}

// Fallback in case we never receive the users list after joining the call
setTimeout(() => {
// If, by accident, we never receive a users list, just switch to
// "Waiting for others to join the call …" after some seconds.
finishConnecting()
}, 10000)

EventBus.once('signaling-join-call', handleJoinCall)
EventBus.once('signaling-join-call-failed', handleJoinCallFailed)
EventBus.on('signaling-users-in-room', handleUsersInRoom)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Signaling.Base.prototype.joinCall = function(token, flags, silent, recordingCons
this.currentCallFlags = flags
this.currentCallSilent = silent
this.currentCallRecordingConsent = recordingConsent
this._trigger('joinCall', [token])
this._trigger('joinCall', [token, flags])
resolve()
this._joinCallSuccess(token)
}.bind(this))
Expand Down Expand Up @@ -1225,7 +1225,7 @@ Signaling.Standalone.prototype.joinCall = function(token, flags, silent, recordi
this.currentCallFlags = flags
this.currentCallSilent = silent
this.currentCallRecordingConsent = recordingConsent
this._trigger('joinCall', [token])
this._trigger('joinCall', [token, flags])

resolve()
})
Expand Down

0 comments on commit 085aca1

Please sign in to comment.