diff --git a/src/components/CallView/Grid/Grid.vue b/src/components/CallView/Grid/Grid.vue index 22f7cda8abc..a47b5e63d19 100644 --- a/src/components/CallView/Grid/Grid.vue +++ b/src/components/CallView/Grid/Grid.vue @@ -513,10 +513,6 @@ export default { return this.videos } - if (!this.participantsInitialised) { - return [] - } - const objectMap = { modelsWithScreenshare: [], modelsTempPromoted: [], @@ -536,7 +532,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 4ad64ea0422..bdfd3206e06 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.$store.getters.getUserId() - }, - 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.$store.getters.getUserId() : user.actorId === this.$store.getters.getActorId() + }) 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.$store.getters.getAttendeeId()) + 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 2aa14be4c4b..f489e231cb5 100644 --- a/src/composables/useGetParticipants.js +++ b/src/composables/useGetParticipants.js @@ -89,7 +89,7 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { } const onJoinedConversation = () => { - if (isOneToOneConversation.value) { + if (isOneToOneConversation.value || experimentalUpdateParticipants) { cancelableGetParticipants() } else { nextTick(() => throttleUpdateParticipants()) @@ -119,36 +119,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(() => { @@ -157,6 +147,10 @@ export function useGetParticipants(isActive = ref(true), isTopBar = true) { } }) + watch(token, () => { + cancelPendingUpdates() + }) + watch(isActive, (newValue) => { if (newValue && pendingChanges) { throttleUpdateParticipants() @@ -164,11 +158,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 9fd954a8171..046b74d51c5 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -318,6 +318,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 95cef799dc9..226a4cfd4f9 100644 --- a/src/store/conversationsStore.spec.js +++ b/src/store/conversationsStore.spec.js @@ -104,6 +104,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 }, @@ -159,6 +160,7 @@ describe('conversationsStore', () => { inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED, lastPing: 600, participantType: PARTICIPANT.TYPE.USER, + permissions: PARTICIPANT.PERMISSIONS.CUSTOM, sessionIds: [ 'session-id-1', ], @@ -191,6 +193,7 @@ describe('conversationsStore', () => { inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED, lastPing: 600, participantType: PARTICIPANT.TYPE.USER, + permissions: PARTICIPANT.PERMISSIONS.CUSTOM, sessionIds: [ 'session-id-1', ],