From 161a9b233cd74dec96bcf3bf727da68c48bed1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 13 Aug 2023 06:23:55 +0200 Subject: [PATCH 1/5] Update timestamp only when starting to speak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The timestamp is only used to calculate the elapsed speaking time when stopping to speak, so it needs to be updated only when starting to speak. Additionally, in some cases "speaking" can also be set to "undefined" (for example, when a remote participant leaves the call); from the point of view of tracking the speaking time any falsy value is false, so the value is explicitly set to true/false. Signed-off-by: Daniel Calviño Sánchez --- src/store/participantsStore.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index 1bd09bce1f8..540810092be 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -371,12 +371,10 @@ const mutations = { // when speaking has stopped, update the total talking time if (currentSpeakingState && !speaking && state.speaking[token][sessionId].lastTimestamp) { + state.speaking[token][sessionId].speaking = false state.speaking[token][sessionId].totalCountedTime += (currentTimestamp - state.speaking[token][sessionId].lastTimestamp) - } - - // don't change state for consecutive identical signals - if (currentSpeakingState !== speaking) { - state.speaking[token][sessionId].speaking = speaking + } else if (!currentSpeakingState && speaking) { + state.speaking[token][sessionId].speaking = true state.speaking[token][sessionId].lastTimestamp = currentTimestamp } }, From b0659e66d4ae8bc9fbf40525608bd05868a2ed01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 13 Aug 2023 06:25:32 +0200 Subject: [PATCH 2/5] Remove unneeded condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The counted time is updated if a participant is speaking and then stops speaking; the timestamp is updated when a participant starts speaking, so the timestamp was already updated back then and therefore there is no need to explicitly check that. Signed-off-by: Daniel Calviño Sánchez --- src/store/participantsStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index 540810092be..d563967a294 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -370,7 +370,7 @@ const mutations = { const currentSpeakingState = state.speaking[token][sessionId].speaking // when speaking has stopped, update the total talking time - if (currentSpeakingState && !speaking && state.speaking[token][sessionId].lastTimestamp) { + if (currentSpeakingState && !speaking) { state.speaking[token][sessionId].speaking = false state.speaking[token][sessionId].totalCountedTime += (currentTimestamp - state.speaking[token][sessionId].lastTimestamp) } else if (!currentSpeakingState && speaking) { From 5fb9c977f949f03bbed766a67284c121ae51badb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 13 Aug 2023 06:26:38 +0200 Subject: [PATCH 3/5] Reorder blocks to match the normal flow of state changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After being initialized the speaking value will be first modified when the participant starts speaking, and then once the participant stops speaking. Signed-off-by: Daniel Calviño Sánchez --- src/store/participantsStore.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index d563967a294..65e4fd1f6c9 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -369,13 +369,13 @@ const mutations = { const currentTimestamp = Date.now() const currentSpeakingState = state.speaking[token][sessionId].speaking - // when speaking has stopped, update the total talking time - if (currentSpeakingState && !speaking) { - state.speaking[token][sessionId].speaking = false - state.speaking[token][sessionId].totalCountedTime += (currentTimestamp - state.speaking[token][sessionId].lastTimestamp) - } else if (!currentSpeakingState && speaking) { + if (!currentSpeakingState && speaking) { state.speaking[token][sessionId].speaking = true state.speaking[token][sessionId].lastTimestamp = currentTimestamp + } else if (currentSpeakingState && !speaking) { + // when speaking has stopped, update the total talking time + state.speaking[token][sessionId].speaking = false + state.speaking[token][sessionId].totalCountedTime += (currentTimestamp - state.speaking[token][sessionId].lastTimestamp) } }, From 1ac74f976047e6394b26a55d2bb51174b34c2881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 13 Aug 2023 06:27:02 +0200 Subject: [PATCH 4/5] Fix documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- src/store/participantsStore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/participantsStore.js b/src/store/participantsStore.js index 65e4fd1f6c9..e12dce55f5d 100644 --- a/src/store/participantsStore.js +++ b/src/store/participantsStore.js @@ -348,8 +348,8 @@ const mutations = { * property to an existing participant, as the participant would be reset * when the participants are purged whenever they are fetched again. * Similarly, "addParticipant" can not be called either to add a participant - * if it was not fetched yet but the signaling reported it as being speaking, - * as the attendeeId would be unknown. + * if it was not fetched yet but the call model reported it as being + * speaking, as the attendeeId would be unknown. * * @param {object} state - current store state. * @param {object} data - the wrapping object. From 2586e220427364b1f0c3da9daef7f35551a22ce2 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Mon, 14 Aug 2023 20:16:15 +0200 Subject: [PATCH 5/5] introduce computed variable whether to show speaking time and status or not Signed-off-by: Maksim Sukharev --- .../ParticipantsList/Participant/Participant.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue b/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue index 6a161e3f402..791ad2cd77f 100644 --- a/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue +++ b/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue @@ -40,7 +40,7 @@ disable-tooltip :show-user-status="showUserStatus && !isSearched" :preloaded-user-status="preloadedUserStatus" - :highlighted="isParticipantSpeaking" + :highlighted="isSpeakingStatusAvailable && isParticipantSpeaking" :offline="isOffline" /> @@ -349,8 +349,12 @@ export default { return text }, + isSpeakingStatusAvailable() { + return this.isInCall && !!this.participant.inCall && !!this.timeSpeaking + }, + statusMessage() { - if (this.isInCall && this.participant.inCall && this.timeSpeaking) { + if (this.isSpeakingStatusAvailable) { return this.isParticipantSpeaking ? '💬 ' + t('spreed', '{time} talking …', { time: formattedTime(this.timeSpeaking, true) }) : '💬 ' + t('spreed', '{time} talking time', { time: formattedTime(this.timeSpeaking, true) })