mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 07:07:18 +00:00
fix(webui): robust auto-pagination for virtualized file views
This commit is contained in:
@@ -176,23 +176,21 @@ export function FileBrowserGridView({
|
||||
for (const virtualItem of virtualItems) {
|
||||
const row = rows[virtualItem.index]
|
||||
if (row?.type === 'row') {
|
||||
if (row.kind === 'folder') {
|
||||
const lastIndex = (row.rowIndex + 1) * cols
|
||||
if (
|
||||
lastIndex >= folders.length - cols * 2 &&
|
||||
hasNextFoldersPage &&
|
||||
!isFetchingNextFoldersPage
|
||||
) {
|
||||
const isFolder = row.kind === 'folder'
|
||||
const dataList = isFolder ? folders : files
|
||||
const startIndex = row.rowIndex * cols
|
||||
const isSkeleton = !dataList[startIndex] // Check if the first item in row is loaded
|
||||
const isNearEnd = startIndex >= dataList.length - cols * 3
|
||||
|
||||
if (isFolder && hasNextFoldersPage && !isFetchingNextFoldersPage) {
|
||||
if (isSkeleton || isNearEnd) {
|
||||
fetchNextFoldersPage()
|
||||
break
|
||||
}
|
||||
} else if (row.kind === 'file') {
|
||||
const lastIndex = (row.rowIndex + 1) * cols
|
||||
if (
|
||||
lastIndex >= files.length - cols * 2 &&
|
||||
hasNextFilesPage &&
|
||||
!isFetchingNextFilesPage
|
||||
) {
|
||||
} else if (!isFolder && hasNextFilesPage && !isFetchingNextFilesPage) {
|
||||
if (isSkeleton || isNearEnd) {
|
||||
fetchNextFilesPage()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,20 +262,22 @@ export function FileBrowserListView({
|
||||
for (const virtualItem of virtualItems) {
|
||||
const item = items[virtualItem.index]
|
||||
if (item?.type === 'item') {
|
||||
if (
|
||||
item.kind === 'folder' &&
|
||||
item.index >= folders.length - 10 &&
|
||||
hasNextFoldersPage &&
|
||||
!isFetchingNextFoldersPage
|
||||
) {
|
||||
fetchNextFoldersPage()
|
||||
} else if (
|
||||
item.kind === 'file' &&
|
||||
item.index >= files.length - 10 &&
|
||||
hasNextFilesPage &&
|
||||
!isFetchingNextFilesPage
|
||||
) {
|
||||
fetchNextFilesPage()
|
||||
const isSkeleton = item.kind === 'folder' ? !folders[item.index] : !files[item.index]
|
||||
const isNearEnd =
|
||||
item.kind === 'folder'
|
||||
? item.index >= folders.length - 15
|
||||
: item.index >= files.length - 15
|
||||
|
||||
if (item.kind === 'folder' && hasNextFoldersPage && !isFetchingNextFoldersPage) {
|
||||
if (isSkeleton || isNearEnd) {
|
||||
fetchNextFoldersPage()
|
||||
break
|
||||
}
|
||||
} else if (item.kind === 'file' && hasNextFilesPage && !isFetchingNextFilesPage) {
|
||||
if (isSkeleton || isNearEnd) {
|
||||
fetchNextFilesPage()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user