From 2c34fa91be59361fbb872dcab751a887a92a02ab 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: 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 1bd09bce1..540810092 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 } }, -- cgit v1.2.3