Merge pull request #47157 from nextcloud/perf/prevent-extra-requests

perf(files): Prevent extraneous requests when tree children are loading
pull/46987/head
Pytal 9 months ago committed by GitHub
commit 4a512d408d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      apps/files/src/views/folderTree.ts
  2. 4
      dist/files-init.js
  3. 2
      dist/files-init.js.map

@ -31,6 +31,7 @@ const isFolderTreeEnabled = loadState('files', 'config', { folder_tree: true }).
const Navigation = getNavigation() const Navigation = getNavigation()
const queue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 }) const queue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })
const registerQueue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 }) const registerQueue = new PQueue({ concurrency: 5, intervalCap: 5, interval: 200 })
const registerTreeNodes = async (path: string = '/') => { const registerTreeNodes = async (path: string = '/') => {
@ -44,16 +45,12 @@ const registerTreeNodes = async (path: string = '/') => {
const getLoadChildViews = (node: TreeNode | Folder) => { const getLoadChildViews = (node: TreeNode | Folder) => {
return async (view: View): Promise<void> => { return async (view: View): Promise<void> => {
// @ts-expect-error Custom property on View instance // @ts-expect-error Custom property on View instance
if (view.loaded) { if (view.loading || view.loaded) {
return return
} }
// @ts-expect-error Custom property // @ts-expect-error Custom property
view.loading = true view.loading = true
try { await registerTreeNodes(node.path)
await registerTreeNodes(node.path)
} catch (error) {
// Skip duplicate view registration errors
}
// @ts-expect-error Custom property // @ts-expect-error Custom property
view.loading = false view.loading = false
// @ts-expect-error Custom property // @ts-expect-error Custom property

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save