Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down