Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Call): introduce intermediary phase before joining call #13329

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/components/CallView/CallFailedDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

<script setup lang="ts">
import { computed } from 'vue'

import IconAlertOctagon from 'vue-material-design-icons/AlertOctagon.vue'

import { t } from '@nextcloud/l10n'

import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved

import { useStore } from '../../composables/useStore.js'

const store = useStore()

const props = defineProps({
token: {
type: String,
required: true,
},
})

const STATUS_ERRORS = {
400: t('spreed', 'Recording consent is required'),
403: t('spreed', 'This conversation is read-only'),
404: t('spreed', 'Conversation not found or not joined'),
412: t('spreed', "Lobby is still active and you're not a moderator"),
}
const userId = computed(() => store.getters.userId)
const connectionFailed = computed(() => store.getters.connectionFailed(props.token))
const connectionFailedDialogId = `connection-failed-${userId.value}`
const message = computed(() => {
if (connectionFailed.value) {
const statusCode = connectionFailed.value?.meta?.statuscode
if (STATUS_ERRORS[statusCode]) {
return STATUS_ERRORS[statusCode]
}
if (connectionFailed.value?.data?.error) {
return connectionFailed.value.data.error
}

return t('spreed', 'Please try to reload the page')
} else {
return ''
}
})

/**
*
*/
function clearConnectionFailedError() {
store.dispatch('clearConnectionFailed', props.token)
}

</script>

<template>
<NcModal class="connection-failed__modal"
:label-id="connectionFailedDialogId"
@close="clearConnectionFailedError">
<NcEmptyContent :name="t('spreed', 'Connection failed')"
:description="message">
<template #icon>
<IconAlertOctagon />
</template>
</NcEmptyContent>
</NcModal>
</template>
42 changes: 2 additions & 40 deletions src/components/CallView/shared/EmptyCallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<p v-if="message" class="emptycontent-additional">
{{ message }}
</p>
<p v-if="helper" class="emptycontent-additional">
{{ helper }}
</p>
<NcButton v-if="showLink"
type="primary"
@click.stop="handleCopyLink">
Expand All @@ -30,7 +27,6 @@

<script>
import IconAccountMultiple from 'vue-material-design-icons/AccountMultiple.vue'
import IconAlertOctagon from 'vue-material-design-icons/AlertOctagon.vue'
import IconLinkVariant from 'vue-material-design-icons/LinkVariant.vue'
import IconPhone from 'vue-material-design-icons/Phone.vue'

Expand All @@ -42,24 +38,16 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import { CONVERSATION, PARTICIPANT } from '../../../constants.js'
import { copyConversationLinkToClipboard } from '../../../utils/handleUrl.ts'

const STATUS_ERRORS = {
400: t('spreed', 'Recording consent is required'),
403: t('spreed', 'This conversation is read-only'),
404: t('spreed', 'Conversation not found or not joined'),
412: t('spreed', "Lobby is still active and you're not a moderator"),
}

export default {

name: 'EmptyCallView',

components: {
NcButton,
NcLoadingIcon,
IconAccountMultiple,
IconAlertOctagon,
IconLinkVariant,
IconPhone,
NcLoadingIcon,
},

props: {
Expand All @@ -80,7 +68,6 @@ export default {
},

computed: {

token() {
return this.$store.getters.getToken()
},
Expand All @@ -89,10 +76,6 @@ export default {
return this.$store.getters.isConnecting(this.token)
},

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

conversation() {
return this.$store.getters.conversation(this.token)
},
Expand Down Expand Up @@ -138,9 +121,7 @@ export default {
},

emptyCallViewIcon() {
if (this.connectionFailed) {
return IconAlertOctagon
} else if (this.isConnecting) {
if (this.isConnecting) {
return NcLoadingIcon
} else if (this.isPhoneConversation) {
return IconPhone
Expand All @@ -150,9 +131,6 @@ export default {
},

title() {
if (this.connectionFailed) {
return t('spreed', 'Connection failed')
}
if (this.isConnecting) {
return t('spreed', 'Connecting โ€ฆ')
}
Expand All @@ -165,23 +143,7 @@ export default {
return t('spreed', 'Waiting for others to join the call โ€ฆ')
},

helper() {
return this.connectionFailed ? t('spreed', 'Please try to reload the page') : ''
},

message() {
if (this.connectionFailed) {
const statusCode = this.connectionFailed?.meta?.statuscode
if (STATUS_ERRORS[statusCode]) {
return STATUS_ERRORS[statusCode]
}
if (this.connectionFailed?.data?.error) {
return this.connectionFailed.data.error
}

return t('spreed', 'Something went wrong')
}

if (this.isConnecting) {
return ''
}
Expand Down
24 changes: 22 additions & 2 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
id="call_button"
:title="startCallTitle"
:aria-label="startCallLabel"
:disabled="startCallButtonDisabled || loading"
:disabled="startCallButtonDisabled || loading || isJoiningCall"
:type="startCallButtonType"
@click="handleClick">
<template #icon>
<IconPhoneDial v-if="isPhoneRoom" :size="20" />
<NcLoadingIcon v-if="isJoiningCall || loading" />
<IconPhoneDial v-else-if="isPhoneRoom" :size="20" />
<IconPhoneOutline v-else-if="silentCall" :size="20" />
<IconPhone v-else :size="20" />
</template>
<template v-if="showButtonText" #default>
{{ startCallLabel }}
</template>
</NcButton>

<NcButton v-else-if="showLeaveCallButton && canEndForAll && isPhoneRoom"
id="call_button"
:aria-label="endCallLabel"
Expand Down Expand Up @@ -77,6 +79,7 @@
{{ t('spreed', 'End call for everyone') }}
</NcActionButton>
</NcActions>
<CallFailedDialog v-if="connectionFailed" :token="token" />
</div>
</template>

Expand All @@ -96,8 +99,11 @@ import { t } from '@nextcloud/l10n'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import { useIsMobile } from '@nextcloud/vue/dist/Composables/useIsMobile.js'

import CallFailedDialog from '../CallView/CallFailedDialog.vue'

import { useIsInCall } from '../../composables/useIsInCall.js'
import { ATTENDEE, CALL, CONVERSATION, PARTICIPANT } from '../../constants.js'
import { callSIPDialOut } from '../../services/callsService.js'
Expand All @@ -113,6 +119,7 @@ export default {
name: 'CallButton',

components: {
CallFailedDialog,
NcActions,
NcActionButton,
NcButton,
Expand All @@ -123,6 +130,7 @@ export default {
IconPhoneHangup,
IconPhoneOff,
IconPhoneOutline,
NcLoadingIcon,
},

props: {
Expand Down Expand Up @@ -266,6 +274,10 @@ export default {
return t('spreed', 'Join call')
}

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

return this.silentCall ? t('spreed', 'Start call silently') : t('spreed', 'Start call')
},

Expand Down Expand Up @@ -332,6 +344,14 @@ export default {
isInLobby() {
return this.$store.getters.isInLobby
},

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

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

watch: {
Expand Down
6 changes: 1 addition & 5 deletions src/services/callsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ import {
* @return {number} The actual flags based on the available media
*/
const joinCall = async function(token, flags, silent, recordingConsent) {
try {
return await signalingJoinCall(token, flags, silent, recordingConsent)
} catch (error) {
console.debug('Error while joining call: ', error)
}
return await signalingJoinCall(token, flags, silent, recordingConsent)
}

/**
Expand Down
Loading