Skip to content

Commit

Permalink
Merge pull request #12509 from sanskar-soni-9/feat/auto-lower-hand-on…
Browse files Browse the repository at this point in the history
…-mic-on

feat(call): auto lower hand on speaking for 3s
  • Loading branch information
Antreesy authored Jun 18, 2024
2 parents 94df2b6 + ae722d0 commit c6071c3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts'
import { generateAbsoluteUrl } from '../../utils/handleUrl.ts'
import { callParticipantCollection } from '../../utils/webrtc/index.js'
const AUTO_LOWER_HAND_THRESHOLD = 3000
export default {
name: 'TopBarMenu',
Expand Down Expand Up @@ -252,6 +254,9 @@ export default {
data() {
return {
boundaryElement: document.querySelector('.main-view'),
lowerHandTimeout: null,
speakingTimestamp: null,
lowerHandDelay: AUTO_LOWER_HAND_THRESHOLD,
}
},
Expand Down Expand Up @@ -376,7 +381,39 @@ export default {
showCallLayoutSwitch() {
return !this.$store.getters.isEmptyCallView
}
},
},
watch: {
'model.attributes.speaking'(speaking) {
// user stops speaking in lowerHandTimeout
if (this.lowerHandTimeout !== null && !speaking) {
this.lowerHandDelay = Math.max(0, this.lowerHandDelay - (Date.now() - this.speakingTimestamp))
clearTimeout(this.lowerHandTimeout)
this.lowerHandTimeout = null
return
}
// user is not speaking OR timeout is already running OR hand is not raised
if (!speaking || this.lowerHandTimeout !== null || !this.isHandRaised) {
return
}
this.speakingTimestamp = Date.now()
this.lowerHandTimeout = setTimeout(() => {
this.lowerHandTimeout = null
this.speakingTimestamp = null
this.lowerHandDelay = AUTO_LOWER_HAND_THRESHOLD
if (this.isHandRaised) {
this.toggleHandRaised()
}
}, this.lowerHandDelay)
},
},
methods: {
Expand Down

0 comments on commit c6071c3

Please sign in to comment.