Skip to content

Commit

Permalink
Merge pull request #47157 from nextcloud/perf/prevent-extra-requests
Browse files Browse the repository at this point in the history
perf(files): Prevent extraneous requests when tree children are loading
  • Loading branch information
Pytal authored Aug 10, 2024
2 parents d50b6da + d0186fe commit 4a512d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions apps/files/src/views/folderTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const isFolderTreeEnabled = loadState('files', 'config', { folder_tree: true }).
const Navigation = getNavigation()

const queue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })

const registerQueue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })

const registerTreeNodes = async (path: string = '/') => {
Expand All @@ -44,16 +45,12 @@ const registerTreeNodes = async (path: string = '/') => {
const getLoadChildViews = (node: TreeNode | Folder) => {
return async (view: View): Promise<void> => {
// @ts-expect-error Custom property on View instance
if (view.loaded) {
if (view.loading || view.loaded) {
return
}
// @ts-expect-error Custom property
view.loading = true
try {
await registerTreeNodes(node.path)
} catch (error) {
// Skip duplicate view registration errors
}
await registerTreeNodes(node.path)
// @ts-expect-error Custom property
view.loading = false
// @ts-expect-error Custom property
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

0 comments on commit 4a512d4

Please sign in to comment.