Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow moderators to force speaker/grid view for everyone #13655

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,19 @@ export default {
return this.callViewStore.isViewerOverlay
},

forcedCallViewMode() {
return this.localCallParticipantModel.attributes.forcedCallViewMode
},

isGrid() {
if (this.forcedCallViewMode === 'grid' && !this.$store.getters.isModerator) {
return true
}

if (this.forcedCallViewMode === 'speaker' && !this.$store.getters.isModerator) {
return false
}

return this.callViewStore.isGrid && !this.isSidebar
},

Expand Down Expand Up @@ -487,6 +499,7 @@ export default {
mounted() {
this.debounceFetchPeers = debounce(this.fetchPeers, 1500)
EventBus.on('refresh-peer-list', this.debounceFetchPeers)
EventBus.on('force-call-view-mode', this.forceCallViewMode)

callParticipantCollection.on('remove', this._lowerHandWhenParticipantLeaves)

Expand All @@ -498,6 +511,7 @@ export default {
this.debounceFetchPeers.clear?.()
this.callViewStore.setIsEmptyCallView(true)
EventBus.off('refresh-peer-list', this.debounceFetchPeers)
EventBus.off('force-call-view-mode', this.forceCallViewMode)

callParticipantCollection.off('remove', this._lowerHandWhenParticipantLeaves)

Expand Down Expand Up @@ -797,6 +811,10 @@ export default {
}
},

forceCallViewMode(mode) {
this.localCallParticipantModel.forceCallViewMode(mode)
},

},
}
</script>
Expand Down
104 changes: 104 additions & 0 deletions src/components/TopBar/CallModerationDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<template>
<NcModal v-if="showCallModerationDialog"
size="small"
:name="t('spreed', 'Moderate the call')"
@close="closeModal">
<div class="call_moderation">
<h2 class="call_moderation--header nc-dialog-alike-header">
{{ t('spreed', 'Moderate the call') }}
</h2>
<p>
{{ t('spreed', 'Force the view mode for all participants') }}
</p>
<div class="call_view_mode">
<NcCheckboxRadioSwitch button-variant
:checked.sync="forcedCallView"
value="grid"
name="grid_view_radio"
type="radio"
button-variant-grouped="vertical">
{{ t('spreed', 'Force Grid view') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch button-variant
:checked.sync="forcedCallView"
value="speaker"
name="speaker_view_radio"
type="radio"
button-variant-grouped="vertical">
{{ t('spreed', 'Force Speaker view') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch button-variant
:checked.sync="forcedCallView"
value="none"
name="none_view_radio"
type="radio"
button-variant-grouped="vertical">
{{ t('spreed', 'None') }}
</NcCheckboxRadioSwitch>
</div>
</div>
</NcModal>
</template>

<script>

import { t } from '@nextcloud/l10n'

import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'

import { EventBus } from '../../services/EventBus.js'
import { localCallParticipantModel } from '../../utils/webrtc/index.js'

export default {
name: 'CallModerationDialog',

components: {
NcModal,
NcCheckboxRadioSwitch
},

props: {
showCallModerationDialog: {
type: Boolean,
default: false
}
},

emits: ['update:showCallModerationDialog'],

Check failure on line 68 in src/components/TopBar/CallModerationDialog.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 1 tab but found 4 spaces

setup() {
return {
localCallParticipantModel,
}
},

data() {
return {
forcedCallView: this.localCallParticipantModel.attributes.forcedCallView ?? 'none',
}
},

watch: {
forcedCallView(value) {
EventBus.emit('force-call-view-mode', value)
},
},

methods: {
t,
closeModal() {
this.$emit('update:showCallModerationDialog', false)
}
}
}
</script>

<style lang="scss" scoped>
.call_moderation {
padding: calc(var(--default-grid-baseline) * 5);
.call_view_mode {
width: fit-content;
}
}
</style>
39 changes: 37 additions & 2 deletions src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<!-- Call layout switcher -->
<NcActionButton v-if="showCallLayoutSwitch"
close-after-click
:disabled="isCallViewChangeDisabled"
@click="changeView">
<template #icon>
<GridView v-if="!isGrid"
Expand All @@ -71,6 +72,14 @@
</template>
{{ changeViewText }}
</NcActionButton>
<NcActionButton v-if="canModerate"
close-after-click
@click="showCallModerationDialog = true">
<template #icon>
<IconAccountGroup :size="20" />
</template>
{{ t('spreed', 'Moderate the call') }}
</NcActionButton>
</template>

<!-- Fullscreen -->
Expand Down Expand Up @@ -148,10 +157,13 @@
{{ t('spreed', 'Download attendance list') }}
</NcActionLink>
</NcActions>

<CallModerationDialog :show-call-moderation-dialog.sync="showCallModerationDialog" />
</div>
</template>

<script>
import IconAccountGroup from 'vue-material-design-icons/AccountGroup.vue'
import Cog from 'vue-material-design-icons/Cog.vue'
import DotsCircle from 'vue-material-design-icons/DotsCircle.vue'
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
Expand Down Expand Up @@ -180,6 +192,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import { useHotKey } from '@nextcloud/vue/dist/Composables/useHotKey.js'

import CallModerationDialog from './CallModerationDialog.vue'
import TransitionExpand from '../MediaSettings/TransitionExpand.vue'

import {
Expand All @@ -193,7 +206,7 @@ import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManage
import { useBreakoutRoomsStore } from '../../stores/breakoutRooms.ts'
import { useCallViewStore } from '../../stores/callView.js'
import { generateAbsoluteUrl } from '../../utils/handleUrl.ts'
import { callParticipantCollection } from '../../utils/webrtc/index.js'
import { callParticipantCollection, localCallParticipantModel } from '../../utils/webrtc/index.js'

const AUTO_LOWER_HAND_THRESHOLD = 3000
const disableKeyboardShortcuts = OCP.Accessibility.disableKeyboardShortcuts()
Expand All @@ -202,6 +215,7 @@ export default {
name: 'TopBarMenu',

components: {
CallModerationDialog,
TransitionExpand,
NcActionButton,
NcActionLink,
Expand All @@ -218,6 +232,7 @@ export default {
FullscreenExit,
GridView,
HandBackLeft,
IconAccountGroup,
IconDownload,
MicrophoneOff,
PromotedView,
Expand Down Expand Up @@ -274,6 +289,8 @@ export default {
lowerHandTimeout: null,
speakingTimestamp: null,
lowerHandDelay: AUTO_LOWER_HAND_THRESHOLD,
showCallModerationDialog: false,
localCallParticipantModel,
}
},

Expand Down Expand Up @@ -309,8 +326,26 @@ export default {
: t('spreed', 'Grid view')
},

forcedCallViewMode() {
return this.localCallParticipantModel.attributes.forcedCallViewMode
},

isCallViewChangeDisabled() {
return !(this.forcedCallViewMode === 'none')
&& !(this.forcedCallViewMode === '')
&& !this.canModerate
},

isGrid() {
return this.callViewStore.isGrid
if (this.forcedCallViewMode === 'grid' && !this.canModerate) {
return true
}

if (this.forcedCallViewMode === 'speaker' && !this.canModerate) {
return false
}

return this.callViewStore.isGrid && !this.isSidebar
},

isVirtualBackgroundAvailable() {
Expand Down
19 changes: 19 additions & 0 deletions src/utils/webrtc/models/LocalCallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export default function LocalCallParticipantModel() {
guestName: null,
peerNeeded: false,
connectionState: null,
forcedCallViewMode: null,
})

this._handleForcedMuteBound = this._handleForcedMute.bind(this)
this._handleForcedCallViewModeBound = this._handleForcedCallViewMode.bind(this)
this._handleExtendedIceConnectionStateChangeBound = this._handleExtendedIceConnectionStateChange.bind(this)

}
Expand All @@ -49,15 +51,18 @@ LocalCallParticipantModel.prototype = {
setWebRtc(webRtc) {
if (this._webRtc) {
this._webRtc.off('forcedMute', this._handleForcedMuteBound)
this._webRtc.off('forcedCallViewMode', this._handleForcedCallViewModeBound)
this._unwatchDisplayNameChange()
}

this._webRtc = webRtc

this.set('peerId', this._webRtc.connection.getSessionId())
this.set('guestName', null)
this.set('forcedCallViewMode', null)

this._webRtc.on('forcedMute', this._handleForcedMuteBound)
this._webRtc.on('forcedCallViewMode', this._handleForcedCallViewModeBound)
this._unwatchDisplayNameChange = store.watch(state => state.actorStore.displayName, this.setGuestName.bind(this))
},

Expand Down Expand Up @@ -120,6 +125,10 @@ LocalCallParticipantModel.prototype = {
this._trigger('forcedMute')
},

_handleForcedCallViewMode(forcedCallViewMode) {
this.set('forcedCallViewMode', forcedCallViewMode)
},

_handleExtendedIceConnectionStateChange(extendedIceConnectionState) {
switch (extendedIceConnectionState) {
case 'new':
Expand Down Expand Up @@ -162,6 +171,16 @@ LocalCallParticipantModel.prototype = {
})
},

forceCallViewMode(callViewMode) {
if (!this._webRtc) {
throw new Error('WebRtc not initialized yet')
}

this._webRtc.sendToAll('control', {
action: 'forceCallViewMode',
callViewMode,
})
},
}

EmitterMixin.apply(LocalCallParticipantModel.prototype)
2 changes: 2 additions & 0 deletions src/utils/webrtc/simplewebrtc/simplewebrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export default function SimpleWebRTC(opts) {
} else {
self.emit('mute', { id: message.payload.peerId })
}
} else if (message.payload.action === 'forceCallViewMode') {
self.emit('forcedCallViewMode', message.payload.callViewMode)
}
} else if (message.type === 'nickChanged') {
// "nickChanged" can be received from a participant without a Peer
Expand Down
Loading