mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Simplify series overview page refresh (#1092)
## Description This PR simplifies refreshing the episode data when returning to the series overview page and reduces the number of queries. Also fixes a race condition when refreshing a single item in the an `ApiRequestPager`. ### Related issues Related to #767 ### Testing Emulator, but will need more testing during actual usage ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
62965c1b22
commit
8bc3384094
3 changed files with 10 additions and 30 deletions
|
|
@ -125,20 +125,6 @@ fun SeriesOverview(
|
||||||
var rowFocused by rememberInt()
|
var rowFocused by rememberInt()
|
||||||
var showDeleteDialog by remember { mutableStateOf<BaseItem?>(null) }
|
var showDeleteDialog by remember { mutableStateOf<BaseItem?>(null) }
|
||||||
|
|
||||||
LaunchedEffect(episodes) {
|
|
||||||
episodes?.let { episodes ->
|
|
||||||
if (episodes is EpisodeList.Success) {
|
|
||||||
if (episodes.episodes.isNotEmpty()) {
|
|
||||||
// TODO focus on first episode when changing seasons?
|
|
||||||
// firstItemFocusRequester.requestFocus()
|
|
||||||
episodes.episodes.getOrNull(position.episodeRowIndex)?.let {
|
|
||||||
viewModel.refreshEpisode(it.id, position.episodeRowIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(position, episodes) {
|
LaunchedEffect(position, episodes) {
|
||||||
val focusedEpisode =
|
val focusedEpisode =
|
||||||
(episodes as? EpisodeList.Success)
|
(episodes as? EpisodeList.Success)
|
||||||
|
|
|
||||||
|
|
@ -387,12 +387,6 @@ class SeriesViewModel
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
this@SeriesViewModel.episodes.value = episodes
|
this@SeriesViewModel.episodes.value = episodes
|
||||||
}
|
}
|
||||||
if (currentEpisodes == null || currentEpisodes.seasonId != seasonId) {
|
|
||||||
(episodes as? EpisodeList.Success)
|
|
||||||
?.let {
|
|
||||||
it.episodes.getOrNull(it.initialEpisodeIndex)
|
|
||||||
}?.let { lookupPeopleInEpisode(it) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ class ApiRequestPager<T>(
|
||||||
position: Int,
|
position: Int,
|
||||||
itemId: UUID,
|
itemId: UUID,
|
||||||
) {
|
) {
|
||||||
|
mutex.withLock {
|
||||||
val item =
|
val item =
|
||||||
api.userLibraryApi.getItem(itemId).content.let {
|
api.userLibraryApi.getItem(itemId).content.let {
|
||||||
BaseItem.from(
|
BaseItem.from(
|
||||||
|
|
@ -156,7 +157,6 @@ class ApiRequestPager<T>(
|
||||||
}
|
}
|
||||||
val pageNumber = position / pageSize
|
val pageNumber = position / pageSize
|
||||||
val index = position - pageNumber * pageSize
|
val index = position - pageNumber * pageSize
|
||||||
mutex.withLock {
|
|
||||||
val page = cachedPages.getIfPresent(pageNumber)
|
val page = cachedPages.getIfPresent(pageNumber)
|
||||||
if (page != null && index in page.indices) {
|
if (page != null && index in page.indices) {
|
||||||
page[index] = item
|
page[index] = item
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue