refactor: optimize delay between batches on mobile to allow UI interactivity during load (#2129)

This commit is contained in:
Mo
2023-01-04 13:31:45 -06:00
committed by GitHub
parent 69b2af7612
commit 59fc68296b
32 changed files with 171 additions and 67 deletions

View File

@@ -11,15 +11,17 @@ import { ItemListController } from './ItemListController'
import { ItemsReloadSource } from './ItemsReloadSource'
describe('item list controller', () => {
let application: WebApplication
let controller: ItemListController
let navigationController: NavigationController
let selectionController: SelectedItemsController
beforeEach(() => {
const application = {} as jest.Mocked<WebApplication>
application = {} as jest.Mocked<WebApplication>
application.streamItems = jest.fn()
application.addEventObserver = jest.fn()
application.addWebEventObserver = jest.fn()
application.isNativeMobileWeb = jest.fn().mockReturnValue(false)
navigationController = {} as jest.Mocked<NavigationController>
selectionController = {} as jest.Mocked<SelectedItemsController>
@@ -50,6 +52,12 @@ describe('item list controller', () => {
})
})
it('should return false is platform is native mobile web', () => {
application.isNativeMobileWeb = jest.fn().mockReturnValue(true)
expect(controller.shouldSelectFirstItem(ItemsReloadSource.TagChange)).toBe(false)
})
it('should return false first item is file', () => {
controller.getFirstNonProtectedItem = jest.fn().mockReturnValue({
content_type: ContentType.File,

View File

@@ -414,6 +414,10 @@ export class ItemListController extends AbstractViewController implements Intern
}
shouldSelectFirstItem = (itemsReloadSource: ItemsReloadSource) => {
if (this.application.isNativeMobileWeb()) {
return false
}
const item = this.getFirstNonProtectedItem()
if (item && isFile(item)) {
return false