ソースを参照

@uppy/provider-views: fix infinite folder loading (#4590)

fix infinite loading bug

this.nextPagePath
Mikael Finstad 1 年間 前
コミット
58c9137bf1

+ 6 - 9
packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx

@@ -108,10 +108,10 @@ export default class ProviderView extends View {
     }
   }
 
-  async #listFilesAndFolders ({ requestPath, breadcrumbs, signal }) {
+  async #listFilesAndFolders ({ breadcrumbs, signal }) {
     const absDirPath = formatBreadcrumbs(breadcrumbs)
 
-    const { items, nextPagePath } = await this.#list({ requestPath, absDirPath, signal })
+    const { items, nextPagePath } = await this.#list({ requestPath: this.nextPagePath, absDirPath, signal })
 
     this.nextPagePath = nextPagePath
 
@@ -164,11 +164,12 @@ export default class ProviderView extends View {
         breadcrumbs = [...breadcrumbs, { requestPath, name }]
       }
 
+      this.nextPagePath = requestPath
       let files = []
       let folders = []
       do {
         const { files: newFiles, folders: newFolders } = await this.#listFilesAndFolders({
-          requestPath, breadcrumbs, signal: controller.signal,
+          breadcrumbs, signal: controller.signal,
         })
 
         files = files.concat(newFiles)
@@ -281,17 +282,13 @@ export default class ProviderView extends View {
   }
 
   async handleScroll (event) {
-    const requestPath = this.nextPagePath || null
-
-    if (this.shouldHandleScroll(event) && requestPath) {
+    if (this.shouldHandleScroll(event) && this.nextPagePath) {
       this.isHandlingScroll = true
 
       try {
         const { files, folders, breadcrumbs } = this.plugin.getPluginState()
 
-        const { files: newFiles, folders: newFolders } = await this.#listFilesAndFolders({
-          requestPath, breadcrumbs,
-        })
+        const { files: newFiles, folders: newFolders } = await this.#listFilesAndFolders({ breadcrumbs })
 
         const combinedFiles = files.concat(newFiles)
         const combinedFolders = folders.concat(newFolders)