diff --git a/src/components/CallView/Grid/Grid.vue b/src/components/CallView/Grid/Grid.vue index 703cb4ce97..feb2525b63 100644 --- a/src/components/CallView/Grid/Grid.vue +++ b/src/components/CallView/Grid/Grid.vue @@ -515,10 +515,6 @@ export default { return this.videos } - if (!this.participantsInitialised) { - return [] - } - const objectMap = { modelsWithScreenshare: [], modelsTempPromoted: [], @@ -538,7 +534,7 @@ export default { objectMap.modelsTempPromoted.push(model) } else if (this.isModelWithVideo(model)) { videoTilesMap.set(model.attributes.nextcloudSessionId, model) - } else if (this.isModelWithAudio(model)) { + } else if (this.participantsInitialised && this.isModelWithAudio(model)) { audioTilesMap.set(model.attributes.nextcloudSessionId, model) } else { objectMap.modelsWithNoPermissions.push(model) diff --git a/src/components/RightSidebar/Participants/ParticipantsTab.vue b/src/components/RightSidebar/Participants/ParticipantsTab.vue index 04327a8d23..da13b52bdf 100644 --- a/src/components/RightSidebar/Participants/ParticipantsTab.vue +++ b/src/components/RightSidebar/Participants/ParticipantsTab.vue @@ -219,10 +219,6 @@ export default { return [CONVERSATION.TYPE.ONE_TO_ONE, CONVERSATION.TYPE.ONE_TO_ONE_FORMER].includes(this.conversation.type) }, - userId() { - return this.actorStore.userId - }, - canAddPhones() { const canModerateSipDialOut = hasTalkFeature(this.token, 'sip-support-dialout') && getTalkConfig(this.token, 'call', 'sip-enabled') @@ -267,9 +263,10 @@ export default { methods: { t, - async updateUsers(usersList) { - const currentUser = usersList.flat().find((user) => user.userId === this.userId) - const currentParticipant = this.participants.find((user) => user.userId === this.userId) + async updateUsers([users]) { + const currentUser = users.find((user) => { + return user.userId ? user.userId === this.actorStore.userId : user.actorId === this.actorStore.actorId + }) if (!currentUser) { return } @@ -277,7 +274,10 @@ export default { if (currentUser.participantPermissions !== this.conversation.permissions) { await this.$store.dispatch('fetchConversation', { token: this.token }) } - if (currentUser.participantPermissions !== currentParticipant?.permissions) { + + const currentParticipant = this.$store.getters.getParticipant(this.token, this.actorStore.attendeeId) + if (currentParticipant && this.$store.getters.isModeratorOrUser + && currentUser.participantPermissions !== currentParticipant?.permissions) { await this.cancelableGetParticipants() } }, diff --git a/src/composables/useGetParticipants.js b/src/composables/useGetParticipants.js index 268e19c1e3..0233cd5d83 100644 --- a/src/composables/useGetParticipants.js +++ b/src/composables/useGetParticipants.js @@ -90,7 +90,7 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { } const onJoinedConversation = () => { - if (isOneToOneConversation.value) { + if (isOneToOneConversation.value || experimentalUpdateParticipants) { cancelableGetParticipants() } else { nextTick(() => throttleUpdateParticipants()) @@ -120,36 +120,26 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { } fetchingParticipants = true - - // Cancel the parallel request queue to not fetch twice - clearTimeout(throttleFastUpdateTimeout) - throttleFastUpdateTimeout = null - clearTimeout(throttleSlowUpdateTimeout) - throttleSlowUpdateTimeout = null - clearTimeout(throttleLongUpdateTimeout) - throttleLongUpdateTimeout = null + cancelPendingUpdates() await store.dispatch('fetchParticipants', { token: token.value }) fetchingParticipants = false } const throttleFastUpdate = () => { - if (throttleFastUpdateTimeout) { - return + if (!fetchingParticipants && !throttleFastUpdateTimeout) { + throttleFastUpdateTimeout = setTimeout(cancelableGetParticipants, 3_000) } - throttleFastUpdateTimeout = setTimeout(cancelableGetParticipants, 3_000) } const throttleSlowUpdate = () => { - if (throttleSlowUpdateTimeout) { - return + if (!fetchingParticipants && !throttleSlowUpdateTimeout) { + throttleSlowUpdateTimeout = setTimeout(cancelableGetParticipants, 15_000) } - throttleSlowUpdateTimeout = setTimeout(cancelableGetParticipants, 15_000) } const throttleLongUpdate = () => { - if (throttleLongUpdateTimeout) { - return + if (!fetchingParticipants && !throttleLongUpdateTimeout) { + throttleLongUpdateTimeout = setTimeout(cancelableGetParticipants, 60_000) } - throttleLongUpdateTimeout = setTimeout(cancelableGetParticipants, 60_000) } onMounted(() => { @@ -158,6 +148,10 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { } }) + watch(token, () => { + cancelPendingUpdates() + }) + watch(isActive, (newValue) => { if (newValue && pendingChanges) { throttleUpdateParticipants() @@ -165,11 +159,25 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { }) onBeforeUnmount(() => { + cancelPendingUpdates() if (isTopBar) { stopGetParticipants() } }) + /** + * Cancel scheduled participant list updates + * Applies to all parallel queues to not fetch twice + */ + function cancelPendingUpdates() { + clearTimeout(throttleFastUpdateTimeout) + throttleFastUpdateTimeout = null + clearTimeout(throttleSlowUpdateTimeout) + throttleSlowUpdateTimeout = null + clearTimeout(throttleLongUpdateTimeout) + throttleLongUpdateTimeout = null + } + return { cancelableGetParticipants, } diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index f62cdc3208..f19089ed0b 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -324,6 +324,7 @@ const actions = { lastPing: conversation.lastPing, sessionIds: [conversation.sessionId], participantType: conversation.participantType, + permissions: conversation.permissions, attendeeId: conversation.attendeeId, actorType: conversation.actorType, actorId: conversation.actorId, // FIXME check public share page handling diff --git a/src/store/conversationsStore.spec.js b/src/store/conversationsStore.spec.js index 14bc7213e5..34f99cc14f 100644 --- a/src/store/conversationsStore.spec.js +++ b/src/store/conversationsStore.spec.js @@ -107,6 +107,7 @@ describe('conversationsStore', () => { attendeeId: 'attendee-id-1', actorType: ATTENDEE.ACTOR_TYPE.USERS, actorId: 'actor-id', + permissions: PARTICIPANT.PERMISSIONS.CUSTOM, defaultPermissions: PARTICIPANT.PERMISSIONS.CUSTOM, callPermissions: PARTICIPANT.PERMISSIONS.CUSTOM, lastMessage: { ...previousLastMessage }, @@ -162,6 +163,7 @@ describe('conversationsStore', () => { inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED, lastPing: 600, participantType: PARTICIPANT.TYPE.USER, + permissions: PARTICIPANT.PERMISSIONS.CUSTOM, sessionIds: [ 'session-id-1', ], @@ -194,6 +196,7 @@ describe('conversationsStore', () => { inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED, lastPing: 600, participantType: PARTICIPANT.TYPE.USER, + permissions: PARTICIPANT.PERMISSIONS.CUSTOM, sessionIds: [ 'session-id-1', ],