Skip to content

Commit

Permalink
fix(SignalingServers): do not emit update event
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Jan 17, 2025
1 parent 9ced227 commit 3253126
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 53 deletions.
16 changes: 7 additions & 9 deletions src/components/AdminSettings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export default {
NcSelect,
},

props: {
hasSignalingServers: {
type: Boolean,
required: true,
},
},

data() {
return {
loading: true,
Expand All @@ -99,7 +106,6 @@ export default {
conversationsFilesPublicShares: parseInt(loadState('spreed', 'conversations_files_public_shares')) === 1,

hasFeatureJoinFeatures: false,
hasSignalingServers: false,
isE2EECallsEnabled: false,
hasSIPBridge: !!loadState('spreed', 'sip_bridge_shared_secret'),
}
Expand All @@ -122,26 +128,18 @@ export default {
this.defaultGroupNotification = defaultGroupNotificationOptions[parseInt(loadState('spreed', 'default_group_notification')) - 1]
this.loading = false

const signaling = loadState('spreed', 'signaling_servers')
this.updateSignalingServers(signaling.servers)
EventBus.on('signaling-servers-updated', this.updateSignalingServers)
EventBus.on('signaling-server-connected', this.updateSignalingDetails)
EventBus.on('sip-settings-updated', this.updateSipDetails)
},

beforeDestroy() {
EventBus.off('signaling-servers-updated', this.updateSignalingServers)
EventBus.off('signaling-server-connected', this.updateSignalingDetails)
EventBus.off('sip-settings-updated', this.updateSipDetails)
},

methods: {
t,

updateSignalingServers(servers) {
this.hasSignalingServers = servers.length > 0
},

updateSignalingDetails(signaling) {
this.hasFeatureJoinFeatures = signaling.hasFeature('join-features')
},
Expand Down
21 changes: 8 additions & 13 deletions src/components/AdminSettings/HostedSignalingServer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->

<template>
<section v-if="showForm"
<section v-if="!hasSignalingServers || trialAccount.length !== 0"
id="hosted_signaling_server"
class="hosted-signaling section">
<h2>
Expand Down Expand Up @@ -140,6 +140,13 @@ export default {
NcTextField,
},

props: {
hasSignalingServers: {
type: Boolean,
required: true,
},
},

data() {
return {
hostedHPBNextcloudUrl: '',
Expand Down Expand Up @@ -209,14 +216,6 @@ export default {

this.hostedHPBLanguage = this.languages.find(language => language.code === state.language) ?? this.languages[0]
this.hostedHPBCountry = this.countries.find(country => country.code === state.country) ?? this.countries[0]

const signaling = loadState('spreed', 'signaling_servers')
this.updateSignalingServers(signaling.servers)
EventBus.on('signaling-servers-updated', this.updateSignalingServers)
},

beforeDestroy() {
EventBus.off('signaling-servers-updated', this.updateSignalingServers)
},

methods: {
Expand Down Expand Up @@ -256,10 +255,6 @@ export default {
this.loading = false
}
},

updateSignalingServers(servers) {
this.showForm = this.trialAccount.length !== 0 || servers.length === 0
},
},
}
</script>
Expand Down
19 changes: 8 additions & 11 deletions src/components/AdminSettings/RecordingServers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ t('spreed', 'Recording backend') }}
</h2>

<NcNoteCard v-if="!showForm"
<NcNoteCard v-if="!hasSignalingServers"
type="warning"
:text="t('spreed', 'Recording backend configuration is only possible with a High-performance backend.')" />

Expand Down Expand Up @@ -138,6 +138,13 @@ export default {
TransitionWrapper,
},

props: {
hasSignalingServers: {
type: Boolean,
required: true,
},
},

setup() {
return {
recordingConsentCapability,
Expand All @@ -152,7 +159,6 @@ export default {
uploadLimit: 0,
loading: false,
saved: false,
showForm: true,
recordingConsentSelected: loadState('spreed', 'recording_consent').toString(),
recordingTranscriptionEnabled: loadState('spreed', 'call_recording_transcription'),
recordingSummaryEnabled: loadState('spreed', 'call_recording_summary'),
Expand All @@ -178,15 +184,10 @@ export default {
this.servers = state.servers
this.secret = state.secret
this.uploadLimit = parseInt(state.uploadLimit, 10)

const signaling = loadState('spreed', 'signaling_servers')
this.updateSignalingServers(signaling.servers)
EventBus.on('signaling-servers-updated', this.updateSignalingServers)
},

beforeDestroy() {
this.debounceUpdateServers.clear?.()
EventBus.off('signaling-servers-updated', this.updateSignalingServers)
},

methods: {
Expand Down Expand Up @@ -265,10 +266,6 @@ export default {
this.saved = false
}, 3000)
},

updateSignalingServers(servers) {
this.showForm = servers.length > 0
},
},
}
</script>
Expand Down
20 changes: 8 additions & 12 deletions src/components/AdminSettings/SIPBridge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div id="sip-bridge" class="sip-bridge section">
<h2>{{ t('spreed', 'SIP configuration') }}</h2>

<NcNoteCard v-if="!showForm"
<NcNoteCard v-if="!hasSignalingServers"
type="warning"
:text="t('spreed', 'SIP configuration is only possible with a High-performance backend.')" />

Expand Down Expand Up @@ -110,11 +110,17 @@ export default {
NcPasswordField,
},

props: {
hasSignalingServers: {
type: Boolean,
required: true,
},
},

data() {
return {
loading: false,
loadingGroups: false,
showForm: true,
groups: [],
sipGroups: [],
dialInInfo: '',
Expand Down Expand Up @@ -148,17 +154,11 @@ export default {
this.debounceSearchGroup('')
this.loading = false
this.saveCurrentSetup()

const signaling = loadState('spreed', 'signaling_servers')
this.updateSignalingServers(signaling.servers)
EventBus.on('signaling-servers-updated', this.updateSignalingServers)

this.isDialoutSupported()
},

beforeDestroy() {
this.debounceSearchGroup.clear?.()
EventBus.off('signaling-servers-updated', this.updateSignalingServers)
},

methods: {
Expand Down Expand Up @@ -229,10 +229,6 @@ export default {
}
}
},

updateSignalingServers(servers) {
this.showForm = servers.length > 0
},
},
}
</script>
Expand Down
2 changes: 0 additions & 2 deletions src/components/AdminSettings/SignalingServers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
import SignalingServer from '../../components/AdminSettings/SignalingServer.vue'

import { SIGNALING } from '../../constants.js'
import { EventBus } from '../../services/EventBus.ts'
import { InitialState } from '../../types/index.ts'

const isCacheConfigured = loadState('spreed', 'has_cache_configured')
Expand Down Expand Up @@ -177,7 +176,6 @@ function updateServers() {
}), {
success: () => {
showSuccess(t('spreed', 'High-performance backend settings saved'))
EventBus.emit('signaling-servers-updated', serversProxy.value)
loading.value = false
},
})
Expand Down
1 change: 0 additions & 1 deletion src/services/EventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type Events = Record<EventType, unknown> & {
'signaling-join-room': [string],
'signaling-participant-list-changed': void,
'signaling-recording-status-changed': [string, number],
'signaling-servers-updated': { server: string, verify: boolean }[],
'signaling-users-changed': [(Partial<Participant> & ({ sessionId: string } | { nextcloudSessionId: string }))[]],
'signaling-users-in-room': [{ sessionId: string, userId: string }[]],
'smart-picker-open': void,
Expand Down
11 changes: 6 additions & 5 deletions src/views/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->

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

import { loadState } from '@nextcloud/initial-state'

Expand All @@ -31,23 +31,24 @@ const signalingServers = ref<InitialState['spreed']['signaling_servers']>(loadSt
secret: '',
servers: [],
}))
const hasSignalingServers = computed(() => signalingServers.value.servers.length > 0)
</script>

<template>
<div>
<SignalingServers :servers.sync="signalingServers.servers"
:secret.sync="signalingServers.secret"
:hide-warning.sync="signalingServers.hideWarning" />
<HostedSignalingServer />
<GeneralSettings />
<HostedSignalingServer :has-signaling-servers="hasSignalingServers" />
<GeneralSettings :has-signaling-servers="hasSignalingServers" />
<AllowedGroups />
<Federation v-if="supportFederation" />
<BotsSettings />
<WebServerSetupChecks />
<StunServers />
<TurnServers />
<RecordingServers />
<SIPBridge />
<RecordingServers :has-signaling-servers="hasSignalingServers" />
<SIPBridge :has-signaling-servers="hasSignalingServers" />
<MatterbridgeIntegration />
</div>
</template>

0 comments on commit 3253126

Please sign in to comment.