Fix issue with scrolling to the right episode if there are specials in the season (#1827)
## Description Fixes an edge case where clicking on an episode to go to Series Overview wouldn't scroll to the episode if there is a special (season 0) episodes in the episode list. Dev note: to simplify things, if the entire dataset is cached, then just search with `indexOf`. Often the data is cached because 20 seasons or 100 episodes are fetched initially which covers many shows. ### Related issues Follow up to #1708 ### Testing Emulator and unit tests ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
c6d81dada8
commit
548ec09af3
3 changed files with 123 additions and 37 deletions
|
|
@ -11,6 +11,9 @@ import org.junit.Assert
|
|||
import org.junit.Test
|
||||
|
||||
class TestFindIndexByNumberOrId {
|
||||
val season0Id = UUID.randomUUID()
|
||||
val season2Id = UUID.randomUUID()
|
||||
|
||||
fun create(
|
||||
indexNumber: Int,
|
||||
parentIndexNumber: Int,
|
||||
|
|
@ -20,6 +23,12 @@ class TestFindIndexByNumberOrId {
|
|||
type = BaseItemKind.EPISODE,
|
||||
indexNumber = indexNumber,
|
||||
parentIndexNumber = parentIndexNumber,
|
||||
parentId =
|
||||
when (parentIndexNumber) {
|
||||
0 -> season0Id
|
||||
2 -> season2Id
|
||||
else -> null
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -151,4 +160,39 @@ class TestFindIndexByNumberOrId {
|
|||
Assert.assertEquals(2, index)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Test with special in middle`() =
|
||||
runTest {
|
||||
val episodes =
|
||||
BlockingList.of<BaseItem?>(
|
||||
listOf(
|
||||
epS02E01,
|
||||
epS02E02,
|
||||
epS02E03,
|
||||
create(6, 0),
|
||||
epS02E04,
|
||||
epS02E05,
|
||||
epS02E06,
|
||||
),
|
||||
)
|
||||
|
||||
findIndexByNumberOrId(
|
||||
targetNum = 3,
|
||||
targetId = epS02E03.id,
|
||||
list = episodes,
|
||||
parentId = season2Id,
|
||||
).let { index ->
|
||||
Assert.assertEquals(2, index)
|
||||
}
|
||||
|
||||
findIndexByNumberOrId(
|
||||
targetNum = 4,
|
||||
targetId = epS02E04.id,
|
||||
list = episodes,
|
||||
parentId = season2Id,
|
||||
).let { index ->
|
||||
Assert.assertEquals(4, index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue