Skip to content

Commit

Permalink
Show a "Connecting …" screen until we finished joining
Browse files Browse the repository at this point in the history
If by accident we never receive a users list, just switch to
"Waiting for others to join the call …" after some seconds.

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 25, 2021
1 parent d4b2724 commit ce4b81c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/CallView/shared/EmptyCallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export default {
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 @@ -95,16 +99,24 @@ export default {
iconClass() {
return {
'icon-public': this.isPublicConversation,
'icon-contacts': !this.isPublicConversation,
'icon-loading': this.isConnecting,
'icon-public': !this.isConnecting && this.isPublicConversation,
'icon-contacts': !this.isConnecting && !this.isPublicConversation,
}
},
title() {
if (this.isConnecting) {
return t('spreed', 'Connecting …')
}
return t('spreed', 'Waiting for others to join the call …')
},
message() {
if (this.isConnecting) {
return ''
}
if (this.isPasswordRequestConversation || this.isFileConversation) {
return ''
}
Expand Down
30 changes: 30 additions & 0 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
leaveCall,
} from '../services/callsService'
import { PARTICIPANT } from '../constants'
import { EventBus } from '../services/EventBus'

const state = {
participants: {
Expand All @@ -39,12 +40,17 @@ const state = {
},
inCall: {
},
connecting: {
},
}

const getters = {
isInCall: (state) => (token) => {
return !!(state.inCall[token] && Object.keys(state.inCall[token]).length > 0)
},
isConnecting: (state) => (token) => {
return !!(state.connecting[token] && Object.keys(state.connecting[token]).length > 0)
},
/**
* Gets the participants array
* @param {object} state the state object.
Expand Down Expand Up @@ -124,11 +130,25 @@ const mutations = {
if (state.inCall[token] && state.inCall[token][sessionId]) {
Vue.delete(state.inCall[token], sessionId)
}

if (state.connecting[token] && state.connecting[token][sessionId]) {
Vue.delete(state.connecting[token], sessionId)
}
} else {
if (!state.inCall[token]) {
Vue.set(state.inCall, token, {})
}
Vue.set(state.inCall[token], sessionId, flags)

if (!state.connecting[token]) {
Vue.set(state.connecting, token, {})
}
Vue.set(state.connecting[token], sessionId, flags)
}
},
finishedConnecting(state, { token, sessionId }) {
if (state.connecting[token] && state.connecting[token][sessionId]) {
Vue.delete(state.connecting[token], sessionId)
}
},
/**
Expand Down Expand Up @@ -286,6 +306,16 @@ const actions = {
inCall: flags,
}
commit('updateParticipant', { token, index, updatedData })

EventBus.$once('Signaling::usersInRoom', () => {
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)
},

async leaveCall({ commit, getters }, { token, participantIdentifier }) {
Expand Down

0 comments on commit ce4b81c

Please sign in to comment.