Skip to content

Commit

Permalink
fix: extract placeholder mocks to separate file
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Antreesy committed Aug 19, 2024

Verified

This commit was signed with the committer’s verified signature.
blizzz Arthur Schiwon
1 parent a4b5d15 commit 6508165
Showing 2 changed files with 98 additions and 74 deletions.
84 changes: 10 additions & 74 deletions src/components/CallView/Grid/Grid.vue
Original file line number Diff line number Diff line change
@@ -57,11 +57,11 @@
</template>
<!-- Grid developer mode -->
<template v-if="devMode">
<div v-for="(video, key) in displayedVideos"
:key="video"
<div v-for="key in displayedVideos"
:key="key"
class="dev-mode-video video"
:class="{'dev-mode-screenshot': screenshotMode}">
<img :src="placeholderImage(key)">
<img :alt="placeholderName(key)" :src="placeholderImage(key)">
<VideoBottomBar :has-shadow="false"
:model="placeholderModel(key)"
:shared-data="placeholderSharedData(key)"
@@ -135,7 +135,6 @@ import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { generateFilePath } from '@nextcloud/router'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'

@@ -145,6 +144,7 @@ import LocalVideo from '../shared/LocalVideo.vue'
import VideoBottomBar from '../shared/VideoBottomBar.vue'
import VideoVue from '../shared/VideoVue.vue'

import { placeholderImage, placeholderModel, placeholderName, placeholderSharedData } from './gridPlaceholders.ts'
import { PARTICIPANT, ATTENDEE } from '../../../constants.js'

// Max number of videos per page. `0`, the default value, means no cap
@@ -669,75 +669,11 @@ export default {
}
},

placeholderImage(i) {
return generateFilePath('spreed', 'docs', 'screenshotplaceholders/placeholder-' + i + '.jpeg')
},

placeholderName(i) {
switch (i) {
case 0:
return 'Sandra McKinney'
case 1:
return 'Chris Wurst'
case 2:
return 'Edeltraut Bobb'
case 3:
return 'Arthur Blitz'
case 4:
return 'Roeland Douma'
case 5:
return 'Vanessa Steg'
case 6:
return 'Emily Grant'
case 7:
return 'Tobias Kaminsky'
case 8:
return 'Adrian Ada'
}
},

placeholderModel(i) {
return {
attributes: {
audioAvailable: i === 1 || i === 2 || i === 4 || i === 5 || i === 6 || i === 7 || i === 8,
audioEnabled: i === 8,
videoAvailable: true,
screen: false,
currentVolume: 0.75,
volumeThreshold: 0.75,
localScreen: false,
raisedHand: {
state: i === 0 || i === 1 || i === 6,
},
},
forceMute: () => {},
on: () => {},
off: () => {},
getWebRtc: () => {
return {
connection: {
getSendVideoIfAvailable: () => {},
},
}
},
}
},

placeholderSharedData() {
return {
videoEnabled: {
isVideoEnabled() {
return true
},
},
remoteVideoBlocker: {
isVideoEnabled() {
return true
},
},
screenVisible: false,
}
},
// Placeholder data for devMode and screenshotMode
placeholderImage,
placeholderName,
placeholderModel,
placeholderSharedData,

// whenever the document is resized, re-set the 'clientWidth' variable
handleResize(event) {
@@ -1043,7 +979,7 @@ export default {

.dev-mode-video {
&:not(.dev-mode-screenshot) {
border: 1px solid #00FF41;
outline: 1px solid #00FF41;
color: #00FF41;
}

88 changes: 88 additions & 0 deletions src/components/CallView/Grid/gridPlaceholders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { generateFilePath } from '@nextcloud/router'

/**
* Mock participant image for placeholders
* @param i index
*/
export function placeholderImage(i: number) {
return generateFilePath('spreed', 'docs', 'screenshotplaceholders/placeholder-' + (i % 9) + '.jpeg')
}

/**
* Mock participant name for placeholders
* @param i index
*/
export function placeholderName(i: number): string {
switch (i % 9) {
case 0:
return 'Sandra McKinney'
case 1:
return 'Chris Wurst'
case 2:
return 'Edeltraut Bobb'
case 3:
return 'Arthur Blitz'
case 4:
return 'Roeland Douma'
case 5:
return 'Vanessa Steg'
case 6:
return 'Emily Grant'
case 7:
return 'Tobias Kaminsky'
case 8:
default:
return 'Adrian Ada'
}
}

/**
* Mock participant model for placeholders
* @param i index
*/
export function placeholderModel(i: number) {
return {
attributes: {
audioAvailable: [1, 2, 4, 5, 7, 8].includes(i % 9),
audioEnabled: (i % 9) === 8,
videoAvailable: true,
screen: false,
currentVolume: 0.75,
volumeThreshold: 0.75,
localScreen: false,
raisedHand: {
state: [0, 1, 6].includes(i % 9),
},
},
forceMute: () => {},
on: () => {},
off: () => {},
getWebRtc: () => {
return {
connection: {
getSendVideoIfAvailable: () => {},
},
}
},
}
}

/**
* Mock shared data for placeholders
*/
export function placeholderSharedData() {
return {
videoEnabled: {
isVideoEnabled: () => true,
},
remoteVideoBlocker: {
isVideoEnabled: () => true,
},
screenVisible: false,
}
}

0 comments on commit 6508165

Please sign in to comment.