Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export default {

if (from.name === 'conversation' && from.params.token !== to.params.token) {
this.$store.dispatch('leaveConversation', { token: from.params.token })
this.tokenStore.setLastJoinConversationFailed(false)
}

/**
Expand Down
14 changes: 12 additions & 2 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<NcActions
v-if="showSendActions"
force-menu
:disabled="disabled"
:primary="silentChat"
@close="submenu = null">
<template #icon>
Expand Down Expand Up @@ -512,7 +513,8 @@ export default {
},

disabled() {
return this.isReadOnly || this.noChatPermission || !this.currentConversationIsJoined || this.isRecordingAudio
return this.isReadOnly || this.noChatPermission || this.isRecordingAudio
|| (!this.currentConversationIsJoined && !this.currentConversationIsJoinedWithoutHPB)
},

scheduleMessageTime() {
Expand All @@ -539,7 +541,7 @@ export default {
return t('spreed', 'This conversation has been locked')
} else if (this.noChatPermission) {
return t('spreed', 'No permission to post messages in this conversation')
} else if (!this.currentConversationIsJoined) {
} else if (!this.currentConversationIsJoined && !this.currentConversationIsJoinedWithoutHPB) {
return t('spreed', 'Joining conversation …')
} else if (this.silentChat) {
return t('spreed', 'Write a message without notification')
Expand Down Expand Up @@ -594,6 +596,10 @@ export default {
return this.tokenStore.currentConversationIsJoined
},

currentConversationIsJoinedWithoutHPB() {
return this.tokenStore.currentConversationIsJoinedWithoutHPB
},

currentUploadId() {
return this.$store.getters.currentUploadId
},
Expand Down Expand Up @@ -721,6 +727,10 @@ export default {
this.focusInput()
},

currentConversationIsJoinedWithoutHPB() {
this.focusInput()
},

currentUploadId(value) {
if (value && !this.upload) {
this.text = ''
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewMessage/NewMessageAudioRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:aria-label="startRecordingTitle"
:aria-description="isMediaRecorderLoading ? t('spreed', 'Loading …') : undefined"
variant="tertiary"
:disabled="isMediaRecorderLoading"
:disabled="disabled || isMediaRecorderLoading"
@click="start">
<template #icon>
<IconMicrophoneOutline :size="20" />
Expand Down
3 changes: 3 additions & 0 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ window.OCA.Talk.registerParticipantSearchAction = ({ label, callback, show, icon
EventBus.on('signaling-join-room', ([token]) => {
tokenStore.updateLastJoinedConversationToken(token)
})
EventBus.on('signaling-join-room-failed', ([token]) => {
tokenStore.setLastJoinConversationFailed(true)
})

EventBus.on('signaling-recording-status-changed', ([token, status]) => {
store.dispatch('setConversationProperties', { token, properties: { callRecording: status } })
Expand Down
1 change: 1 addition & 0 deletions src/services/EventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type Events = {
'signaling-join-call': [string, number]
'signaling-join-call-failed': [string, { meta: components['schemas']['OCSMeta'], data: { error: string } }]
'signaling-join-room': [string]
'signaling-join-room-failed': [string]
'signaling-participant-list-changed': void
'signaling-participant-list-updated': void
'signaling-recording-status-changed': [string, number]
Expand Down
19 changes: 19 additions & 0 deletions src/stores/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ export const useTokenStore = defineStore('token', () => {
* A in the signaling server.
*/
const lastJoinedConversationToken = ref<'' | (string & {})>('')
/**
* The joining of a room with the signaling server might fail
* for various reasons. We still want to allow basic functionality
* (e.g. chatting and file sharing) which does not depend on it.
*/
const lastJoinConversationFailed = ref<boolean>(false)

const currentConversationIsJoined = computed(() => token.value !== '' && lastJoinedConversationToken.value === token.value)
const currentConversationIsJoinedWithoutHPB = computed(() => token.value !== '' && lastJoinConversationFailed.value)

/**
* @param newToken token of active conversation
Expand All @@ -43,16 +50,28 @@ export const useTokenStore = defineStore('token', () => {
*/
function updateLastJoinedConversationToken(newToken: string) {
lastJoinedConversationToken.value = newToken
// Reset last failed conversation attempt on successful join
lastJoinConversationFailed.value = false
}

/**
* @param newValue value of the flag for last joined conversation
*/
function setLastJoinConversationFailed(newValue: boolean) {
lastJoinConversationFailed.value = newValue
}

return {
token,
fileIdForToken,
lastJoinedConversationToken,
lastJoinConversationFailed,
currentConversationIsJoined,
currentConversationIsJoinedWithoutHPB,

updateToken,
updateTokenAndFileIdForToken,
updateLastJoinedConversationToken,
setLastJoinConversationFailed,
}
})
22 changes: 21 additions & 1 deletion src/utils/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ function Standalone(settings, urls) {
this.maxReconnectIntervalMs = 16000
this.reconnectIntervalMs = this.initialReconnectIntervalMs
this.helloResponseErrorCount = 0
this.socketErrorCount = 0
this.ownSessionJoined = false
this.joinedUsers = {}
this.rooms = []
Expand Down Expand Up @@ -705,6 +706,7 @@ Signaling.Standalone.prototype.connect = function() {
window.signalingSocket = this.socket
this.socket.onopen = function(event) {
console.debug('Connected', event)
this.socketErrorCount = 0
if (this.signalingConnectionTimeout !== null) {
clearTimeout(this.signalingConnectionTimeout)
this.signalingConnectionTimeout = null
Expand All @@ -713,6 +715,10 @@ Signaling.Standalone.prototype.connect = function() {
this.signalingConnectionWarning.hideToast()
this.signalingConnectionWarning = null
}
if (this.signalingConnectionError !== null) {
this.signalingConnectionError.hideToast()
this.signalingConnectionError = null
}
this.reconnectIntervalMs = this.initialReconnectIntervalMs
if (this.settings.helloAuthParams['2.0']) {
this.waitForWelcomeTimeout = setTimeout(this.welcomeTimeout.bind(this), this.welcomeTimeoutMs)
Expand All @@ -730,10 +736,23 @@ Signaling.Standalone.prototype.connect = function() {
this.signalingConnectionWarning.hideToast()
this.signalingConnectionWarning = null
}
if (this.signalingConnectionError === null) {

this.socketErrorCount++
if (this.signalingConnectionError === null && this.socketErrorCount < 5) {
this.signalingConnectionError = showError(t('spreed', 'Failed to connect. Retrying …'), {
timeout: TOAST_PERMANENT_TIMEOUT,
})
} else if (this.socketErrorCount === 5) {
// Switch to a different message as several errors in a row in hello
// responses indicate that the signaling server might be unable to
// connect to Nextcloud.
if (this.signalingConnectionError) {
this.signalingConnectionError.hideToast()
}
this.signalingConnectionError = showError(t('spreed', 'Failed to connect. The signaling server may be set up incorrectly'), {
timeout: TOAST_PERMANENT_TIMEOUT,
})
this._trigger('joinRoomFailed', [this.settings.token])
}
this.reconnect()
}.bind(this)
Expand Down Expand Up @@ -1082,6 +1101,7 @@ Signaling.Standalone.prototype.helloResponseReceived = function(data) {
this.signalingConnectionError = showError(t('spreed', 'Failed to connect. The signaling server may be set up incorrectly'), {
timeout: TOAST_PERMANENT_TIMEOUT,
})
this._trigger('joinRoomFailed', [this.settings.token])
}

// TODO(fancycode): How should this be handled better?
Expand Down
10 changes: 9 additions & 1 deletion src/utils/webrtc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isCancel } from '@nextcloud/axios'
import { PARTICIPANT, PRIVACY, VIRTUAL_BACKGROUND } from '../../constants.ts'
import BrowserStorage from '../../services/BrowserStorage.js'
import { getTalkConfig } from '../../services/CapabilitiesManager.ts'
import { EventBus } from '../../services/EventBus.ts'
import { fetchSignalingSettings } from '../../services/signalingService.js'
import store from '../../store/index.js'
import { isSafari } from '../browserCheck.ts'
Expand Down Expand Up @@ -220,7 +221,14 @@ function setupWebRtc() {
async function signalingJoinConversation(token, sessionId) {
await connectSignaling(token)
if (tokensInSignaling[token]) {
await signaling.joinRoom(token, sessionId)
try {
await signaling.joinRoom(token, sessionId)
} catch (error) {
// Initial 'signaling.joinRoom' might be in reconnection state
// so it returns a previous token after switch
EventBus.emit('signaling-join-room-failed', [])
throw error
}
}
}

Expand Down