mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 15:44:28 +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) {
|
for (const virtualItem of virtualItems) {
|
||||||
const row = rows[virtualItem.index]
|
const row = rows[virtualItem.index]
|
||||||
if (row?.type === 'row') {
|
if (row?.type === 'row') {
|
||||||
if (row.kind === 'folder') {
|
const isFolder = row.kind === 'folder'
|
||||||
const lastIndex = (row.rowIndex + 1) * cols
|
const dataList = isFolder ? folders : files
|
||||||
if (
|
const startIndex = row.rowIndex * cols
|
||||||
lastIndex >= folders.length - cols * 2 &&
|
const isSkeleton = !dataList[startIndex] // Check if the first item in row is loaded
|
||||||
hasNextFoldersPage &&
|
const isNearEnd = startIndex >= dataList.length - cols * 3
|
||||||
!isFetchingNextFoldersPage
|
|
||||||
) {
|
if (isFolder && hasNextFoldersPage && !isFetchingNextFoldersPage) {
|
||||||
|
if (isSkeleton || isNearEnd) {
|
||||||
fetchNextFoldersPage()
|
fetchNextFoldersPage()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
} else if (row.kind === 'file') {
|
} else if (!isFolder && hasNextFilesPage && !isFetchingNextFilesPage) {
|
||||||
const lastIndex = (row.rowIndex + 1) * cols
|
if (isSkeleton || isNearEnd) {
|
||||||
if (
|
|
||||||
lastIndex >= files.length - cols * 2 &&
|
|
||||||
hasNextFilesPage &&
|
|
||||||
!isFetchingNextFilesPage
|
|
||||||
) {
|
|
||||||
fetchNextFilesPage()
|
fetchNextFilesPage()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,20 +262,22 @@ export function FileBrowserListView({
|
|||||||
for (const virtualItem of virtualItems) {
|
for (const virtualItem of virtualItems) {
|
||||||
const item = items[virtualItem.index]
|
const item = items[virtualItem.index]
|
||||||
if (item?.type === 'item') {
|
if (item?.type === 'item') {
|
||||||
if (
|
const isSkeleton = item.kind === 'folder' ? !folders[item.index] : !files[item.index]
|
||||||
item.kind === 'folder' &&
|
const isNearEnd =
|
||||||
item.index >= folders.length - 10 &&
|
item.kind === 'folder'
|
||||||
hasNextFoldersPage &&
|
? item.index >= folders.length - 15
|
||||||
!isFetchingNextFoldersPage
|
: item.index >= files.length - 15
|
||||||
) {
|
|
||||||
fetchNextFoldersPage()
|
if (item.kind === 'folder' && hasNextFoldersPage && !isFetchingNextFoldersPage) {
|
||||||
} else if (
|
if (isSkeleton || isNearEnd) {
|
||||||
item.kind === 'file' &&
|
fetchNextFoldersPage()
|
||||||
item.index >= files.length - 10 &&
|
break
|
||||||
hasNextFilesPage &&
|
}
|
||||||
!isFetchingNextFilesPage
|
} else if (item.kind === 'file' && hasNextFilesPage && !isFetchingNextFilesPage) {
|
||||||
) {
|
if (isSkeleton || isNearEnd) {
|
||||||
fetchNextFilesPage()
|
fetchNextFilesPage()
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user