diff options
author | Sanskar Soni <sanskarsoni300@gmail.com> | 2024-06-17 23:16:57 +0530 |
---|---|---|
committer | Sanskar Soni <sanskarsoni300@gmail.com> | 2024-06-18 15:01:47 +0530 |
commit | ae722d0917cc2770897a41d8cd9b11214b9f6b7d (patch) | |
tree | b6e6426795183b7ac90ed43cb2b7672d248d41c5 /src | |
parent | a4c8ffcab83c84333733b9dffeb2339fd0d3ec68 (diff) |
feat(call): auto lower raised hand after 3s of speaking
Signed-off-by: Sanskar Soni <sanskarsoni300@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/TopBar/TopBarMenu.vue | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/components/TopBar/TopBarMenu.vue b/src/components/TopBar/TopBarMenu.vue index e847c5f24..0151f4f4c 100644 --- a/src/components/TopBar/TopBarMenu.vue +++ b/src/components/TopBar/TopBarMenu.vue @@ -178,6 +178,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', @@ -251,6 +253,9 @@ export default { data() { return { boundaryElement: document.querySelector('.main-view'), + lowerHandTimeout: null, + speakingTimestamp: null, + lowerHandDelay: AUTO_LOWER_HAND_THRESHOLD, } }, @@ -377,7 +382,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: { |