Skip to content

Commit

Permalink
Merge pull request #10201 from nextcloud/simplify-tracking-of-total-c…
Browse files Browse the repository at this point in the history
…ounted-time

Simplify tracking of total counted time
  • Loading branch information
danxuliu authored Aug 15, 2023
2 parents 263b65d + 2586e22 commit 5f09e11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
disable-tooltip
:show-user-status="showUserStatus && !isSearched"
:preloaded-user-status="preloadedUserStatus"
:highlighted="isParticipantSpeaking"
:highlighted="isSpeakingStatusAvailable && isParticipantSpeaking"
:offline="isOffline" />

<!-- Participant's data -->
Expand Down Expand Up @@ -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) })
Expand Down
18 changes: 8 additions & 10 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -369,15 +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].lastTimestamp) {
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
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)
}
},

Expand Down

0 comments on commit 5f09e11

Please sign in to comment.