refactor: optimize delay between batches on mobile to allow UI interactivity during load (#2129)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user