Skip to content

Commit 6a6fde6

Browse files
committed
files-list: performance optimizations
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
1 parent ff76e25 commit 6a6fde6

4 files changed

Lines changed: 26 additions & 16 deletions

File tree

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
<!-- Menu actions -->
3636
<NcActions v-if="visible"
3737
ref="actionsMenu"
38-
:boundaries-element="getBoundariesElement()"
39-
:container="getBoundariesElement()"
38+
:boundaries-element="getBoundariesElement"
39+
:container="getBoundariesElement"
4040
:disabled="isLoading || loading !== ''"
4141
:force-name="true"
4242
:force-menu="enabledInlineActions.length === 0 /* forceMenu only if no inline actions */"
@@ -70,6 +70,8 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
7070
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
7171
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
7272
73+
import CustomElementRender from '../CustomElementRender.vue'
74+
7375
import logger from '../../logger.js'
7476
7577
// The registered actions list
@@ -83,6 +85,7 @@ export default Vue.extend({
8385
NcActions,
8486
NcIconSvgWrapper,
8587
NcLoadingIcon,
88+
CustomElementRender,
8689
},
8790
8891
props: {
@@ -182,18 +185,18 @@ export default Vue.extend({
182185
this.$emit('update:opened', value)
183186
},
184187
},
185-
},
186188
187-
methods: {
188189
/**
189190
* Making this a function in case the files-list
190191
* reference changes in the future. That way we're
191192
* sure there is one at the time we call it.
192193
*/
193-
getBoundariesElement() {
194+
getBoundariesElement() {
194195
return document.querySelector('.app-content > table.files-list')
195196
},
197+
},
196198
199+
methods: {
197200
actionDisplayName(action: FileAction) {
198201
if (this.filesListWidth < 768 && action.inline && typeof action.title === 'function') {
199202
// if an inline action is rendered in the menu for

apps/files/src/components/FileEntry/FileEntryPreview.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<template>
2323
<span class="files-list__row-icon">
2424
<template v-if="source.type === 'folder'">
25-
<FolderOpenIcon v-if="dragover" />
25+
<FolderOpenIcon v-once v-if="dragover" />
2626
<template v-else>
27-
<FolderIcon />
27+
<FolderIcon v-once />
2828
<OverlayIcon :is="folderOverlay"
2929
v-if="folderOverlay"
3030
class="files-list__row-icon-overlay" />
@@ -41,13 +41,13 @@
4141
@error="backgroundFailed = true"
4242
@load="backgroundFailed = false">
4343

44-
<FileIcon v-else />
44+
<FileIcon v-once v-else />
4545

4646
<!-- Favorite icon -->
4747
<span v-if="isFavorite"
4848
class="files-list__row-icon-favorite"
4949
:aria-label="t('files', 'Favorite')">
50-
<FavoriteIcon />
50+
<FavoriteIcon v-once />
5151
</span>
5252
</span>
5353
</template>

apps/files/src/components/FilesListVirtual.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ export default Vue.extend({
312312
&::v-deep {
313313
// Table head, body and footer
314314
tbody {
315+
will-change: scroll-position, padding;
316+
contain: layout paint style;
315317
display: flex;
316318
flex-direction: column;
317319
width: 100%;
@@ -320,6 +322,7 @@ export default Vue.extend({
320322
321323
/* Hover effect on tbody lines only */
322324
tr {
325+
contain: strict;
323326
&:hover,
324327
&:focus {
325328
background-color: var(--color-background-dark);
@@ -329,6 +332,7 @@ export default Vue.extend({
329332
330333
// Before table and thead
331334
.files-list__before {
335+
contain: strict;
332336
display: flex;
333337
flex-direction: column;
334338
}

apps/files/src/components/VirtualList.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<component :is="dataComponent"
1919
v-for="({key, item}, i) in renderedItems"
2020
:key="key"
21-
:visible="(i >= bufferItems - 1 || index <= bufferItems) && (i <= shownItems - bufferItems)"
21+
:visible="true"
2222
:source="item"
2323
:index="i"
2424
v-bind="extraProps" />
@@ -211,7 +211,7 @@ export default Vue.extend({
211211
}
212212
213213
// Adding scroll listener AFTER the initial scroll to index
214-
this.$el.addEventListener('scroll', this.onScroll)
214+
this.$el.addEventListener('scroll', this.onScroll, { passive: true })
215215
216216
this.$_recycledPool = {} as Record<string, any>
217217
},
@@ -232,11 +232,14 @@ export default Vue.extend({
232232
},
233233
234234
onScroll() {
235-
const topScroll = this.$el.scrollTop - this.beforeHeight
236-
const index = Math.floor(topScroll / this.itemHeight) * this.columnCount
237-
// Max 0 to prevent negative index
238-
this.index = Math.max(0, index)
239-
this.$emit('scroll')
235+
this._onScrollHandle ??= requestAnimationFrame(() => {
236+
this._onScrollHandle = null;
237+
const topScroll = this.$el.scrollTop - this.beforeHeight
238+
const index = Math.floor(topScroll / this.itemHeight) * this.columnCount
239+
// Max 0 to prevent negative index
240+
this.index = Math.max(0, index)
241+
this.$emit('scroll')
242+
});
240243
},
241244
},
242245
})

0 commit comments

Comments
 (0)