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

fix: use provide/inject to pass values of devMode to CallView children #13187

Merged
merged 1 commit into from
Aug 30, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
:local-call-participant-model="localCallParticipantModel"
:shared-datas="sharedDatas"
v-bind="$attrs"
:dev-mode.sync="devMode"
@select-video="handleSelectVideo"
@click-local-video="handleClickLocalVideo" />

Expand Down Expand Up @@ -134,7 +133,7 @@
<script>
import debounce from 'debounce'
import { ref } from 'vue'
import { provide, ref } from 'vue'
import { showMessage } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
Expand Down Expand Up @@ -193,6 +192,9 @@ export default {
setup() {
// For debug and screenshot purposes. Set to true to enable
const devMode = ref(false)
provide('CallView:devModeEnabled', devMode)
const screenshotMode = ref(false)
provide('CallView:screenshotModeEnabled', screenshotMode)
return {
localMediaModel,
Expand Down
23 changes: 8 additions & 15 deletions src/components/CallView/Grid/Grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
:token="token"
:local-media-model="localMediaModel"
:local-call-participant-model="localCallParticipantModel"
:screenshot-mode-url="screenshotMode ? placeholderImage(8) : ''"
@click-video="handleClickLocalVideo" />
</div>
<NcButton v-if="hasNextPage && gridWidth > 0"
Expand All @@ -102,7 +101,6 @@
:token="token"
:local-media-model="localMediaModel"
:local-call-participant-model="localCallParticipantModel"
:screenshot-mode-url="screenshotMode ? placeholderImage(8) : ''"
@click-video="handleClickLocalVideo" />

<template v-if="devMode">
Expand Down Expand Up @@ -141,7 +139,7 @@

<script>
import debounce from 'debounce'
import { ref } from 'vue'
import { inject, ref } from 'vue'
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
import ChevronLeft from 'vue-material-design-icons/ChevronLeft.vue'
Expand Down Expand Up @@ -184,14 +182,6 @@ export default {
},
props: {
/**
* Developer mode: If enabled it allows to debug the grid using dummy
* videos
*/
devMode: {
type: Boolean,
default: false,
},
/**
* Display the overflow of videos in separate pages;
*/
Expand Down Expand Up @@ -244,14 +234,17 @@ export default {
},
},
emits: ['select-video', 'click-local-video', 'update:devMode'],
emits: ['select-video', 'click-local-video'],
setup() {
// Developer mode: If enabled it allows to debug the grid using dummy videos
const devMode = inject('CallView:devModeEnabled', ref(false))
const screenshotMode = inject('CallView:screenshotModeEnabled', ref(false))
// The number of dummy videos in dev mode
const dummies = ref(4)
const screenshotMode = ref(false)
return {
devMode,
dummies,
screenshotMode,
videosCap,
Expand Down Expand Up @@ -688,7 +681,7 @@ export default {
disableDevMode() {
this.screenshotMode = false
this.$emit('update:devMode', false)
this.devMode = false
},
// whenever the document is resized, re-set the 'clientWidth' variable
handleResize(event) {
Expand Down Expand Up @@ -1004,7 +997,7 @@ export default {
object-fit: cover;
height: 100%;
width: 100%;
border-radius: calc(var(--default-clickable-area) / 2);
border-radius: var(--border-radius-element, calc(var(--default-clickable-area) / 2));
}
.wrapper {
Expand Down
27 changes: 22 additions & 5 deletions src/components/CallView/shared/LocalVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
</template>

<script>
import { inject, ref } from 'vue'
import AccountOff from 'vue-material-design-icons/AccountOff.vue'
import { showError, showInfo, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
Expand All @@ -74,6 +76,7 @@ import AvatarWrapper from '../../AvatarWrapper/AvatarWrapper.vue'
import { AVATAR } from '../../../constants.js'
import attachMediaStream from '../../../utils/attachmediastream.js'
import { ConnectionState } from '../../../utils/webrtc/models/CallParticipantModel.js'
import { placeholderImage } from '../Grid/gridPlaceholders.ts'
export default {
Expand Down Expand Up @@ -132,10 +135,6 @@ export default {
type: Boolean,
default: false,
},
screenshotModeUrl: {
type: String,
default: '',
},
isPresenterOverlay: {
type: Boolean,
default: false,
Expand All @@ -144,6 +143,16 @@ export default {
emits: ['click-video', 'click-presenter'],
setup() {
const devMode = inject('CallView:devModeEnabled', ref(false))
const screenshotMode = inject('CallView:screenshotModeEnabled', ref(false))
return {
devMode,
screenshotMode,
}
},
data() {
return {
notificationHandle: null,
Expand Down Expand Up @@ -227,6 +236,10 @@ export default {
isSelectable() {
return !this.unSelectable && !this.isSidebar && this.hasLocalVideo && this.$store.getters.selectedVideoPeerId !== 'local'
},
screenshotModeUrl() {
return this.screenshotMode ? placeholderImage(8) : ''
},
},
watch: {
Expand Down Expand Up @@ -482,7 +495,11 @@ export default {
.dev-mode-video--self {
object-fit: cover !important;
border-radius: calc(var(--default-clickable-area) / 2);
border-radius: var(--border-radius-element, calc(var(--default-clickable-area) / 2));
.presenter-overlay & {
border-radius: 50%;
}
}
.presenter-icon__hide {
Expand Down
34 changes: 30 additions & 4 deletions src/components/CallView/shared/VideoVue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<NcLoadingIcon v-if="isLoading"
:size="avatarSize / 2"
class="video-loading" />

<img v-if="screenshotModeUrl && isPresenterOverlay"
class="dev-mode-video--presenter"
alt="dev-mode-video--presenter"
:src="screenshotModeUrl">
</div>
</TransitionWrapper>
<TransitionWrapper name="fade">
Expand Down Expand Up @@ -79,6 +84,7 @@
<script>
import Hex from 'crypto-js/enc-hex.js'
import SHA1 from 'crypto-js/sha1.js'
import { inject, ref } from 'vue'

import AccountCircle from 'vue-material-design-icons/AccountCircle.vue'
import AccountOff from 'vue-material-design-icons/AccountOff.vue'
Expand All @@ -98,6 +104,7 @@ import { EventBus } from '../../../services/EventBus.js'
import { useGuestNameStore } from '../../../stores/guestName.js'
import attachMediaStream from '../../../utils/attachmediastream.js'
import { ConnectionState } from '../../../utils/webrtc/models/CallParticipantModel.js'
import { placeholderImage } from '../Grid/gridPlaceholders.ts'

export default {

Expand Down Expand Up @@ -193,8 +200,12 @@ export default {
emits: ['click-video', 'click-presenter', 'force-promote-video'],

setup() {
const guestNameStore = useGuestNameStore()
return { guestNameStore }
const screenshotMode = inject('CallView:screenshotModeEnabled', ref(false))

return {
guestNameStore: useGuestNameStore(),
screenshotMode,
}
},

data() {
Expand Down Expand Up @@ -519,6 +530,10 @@ export default {
nextcloudSessionId() {
return this.model.attributes.nextcloudSessionId
},

screenshotModeUrl() {
return this.screenshotMode ? placeholderImage(6) : ''
},
},

watch: {
Expand Down Expand Up @@ -666,8 +681,19 @@ export default {
border-radius: var(--border-radius-element, calc(var(--default-clickable-area) / 2));
}

.videoWrapper.presenter-overlay > video {
border-radius: 50%;
.videoWrapper.presenter-overlay {
& > video {
border-radius: 50%;
}
& > .dev-mode-video--presenter {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
object-fit: cover;
border-radius: 50%;
}
}

.video-loading {
Expand Down
Loading