Skip to content

Commit

Permalink
add ParticipantsListVirtual.vue component
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Sep 14, 2023
1 parent b63940a commit affd2ce
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/AvatarWrapper/AvatarWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
{{ firstLetterOfGuestName }}
</div>
<NcAvatar v-else
:key="id"
:user="id"
:display-name="name"
:menu-container="menuContainerWithFallback"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!--
- @copyright Copyright (c) 2023 Maksim Sukharev <antreesy.web@gmail.com>
-
- @author Grigorii Shartsev <me@shgk.me>
-
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<template>
<RecycleScroller ref="scroller"
list-tag="ul"
item-tag="li"
:items="participants"
:item-size="PARTICIPANT_ITEM_SIZE"
key-field="attendeeId">
<template #default="{ item }">
<Participant :participant="item" tag="div" />
</template>
<template v-if="loading" #after>
<LoadingPlaceholder type="participants" :count="dummyParticipants" />
</template>
</RecycleScroller>
</template>

<script>
import { RecycleScroller } from 'vue-virtual-scroller'

import LoadingPlaceholder from '../../../LoadingPlaceholder.vue'
import Participant from './Participant/Participant.vue'

import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'

const PARTICIPANT_ITEM_SIZE = 64

export default {
name: 'ParticipantsListVirtual',

components: {
LoadingPlaceholder,
Participant,
RecycleScroller,
},

props: {
participants: {
type: Array,
required: true,
},

loading: {
type: Boolean,
default: false,
},
},

setup() {
return {
PARTICIPANT_ITEM_SIZE,
}
},

computed: {
dummyParticipants() {
const dummies = 6 - this.participants.length
return dummies > 0 ? dummies : 0
},
},
}
</script>
6 changes: 4 additions & 2 deletions src/components/RightSidebar/Participants/ParticipantsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
@input="handleInput"
@abort-search="abortSearch" />

<ParticipantsList v-if="!isSearching"
:items="participants"
<ParticipantsListVirtual v-if="!isSearching"
:participants="participants"
:loading="!participantsInitialised" />

<template v-else>
Expand Down Expand Up @@ -62,6 +62,7 @@ import NcAppNavigationCaption from '@nextcloud/vue/dist/Components/NcAppNavigati
import Hint from '../../Hint.vue'
import SearchBox from '../../LeftSidebar/SearchBox/SearchBox.vue'
import ParticipantsList from './ParticipantsList/ParticipantsList.vue'
import ParticipantsListVirtual from './ParticipantsList/ParticipantsListVirtual.vue'
import ParticipantsSearchResults from './ParticipantsSearchResults/ParticipantsSearchResults.vue'

import { useSortParticipants } from '../../../composables/useSortParticipants.js'
Expand All @@ -75,6 +76,7 @@ import CancelableRequest from '../../../utils/cancelableRequest.js'
export default {
name: 'ParticipantsTab',
components: {
ParticipantsListVirtual,
ParticipantsList,
Hint,
NcAppNavigationCaption,
Expand Down

0 comments on commit affd2ce

Please sign in to comment.