Fix counts

This commit is contained in:
Damontecres 2025-10-03 12:03:25 -04:00
parent 8bbcd50385
commit 0595c7174c
No known key found for this signature in database
4 changed files with 13 additions and 9 deletions

View file

@ -65,7 +65,6 @@ class SeasonViewModel
request,
GetItemsRequestHandler,
viewModelScope,
itemCount = item.data.childCount,
)
pager.init()
episodes.value = pager

View file

@ -111,7 +111,6 @@ class SeriesViewModel
request,
GetItemsRequestHandler,
viewModelScope,
itemCount = item.data.childCount,
)
pager.init()
Timber.v("Loaded ${pager.size} seasons for series ${item.id}")

View file

@ -82,11 +82,10 @@ class ApiRequestPager<T>(
val requestHandler: RequestHandler<T>,
private val scope: CoroutineScope,
private val pageSize: Int = DEFAULT_PAGE_SIZE,
itemCount: Int? = null,
cacheSize: Long = 8,
) : AbstractList<BaseItem?>() {
private var items by mutableStateOf(ItemList<BaseItem>(0, pageSize, mapOf()))
private var totalCount by mutableIntStateOf(itemCount ?: -1)
private var totalCount by mutableIntStateOf(-1)
private val mutex = Mutex()
private val cachedPages =
CacheBuilder

View file

@ -5,6 +5,9 @@ import androidx.lifecycle.MutableLiveData
import com.github.damontecres.dolphin.DolphinApplication
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import timber.log.Timber
import kotlin.coroutines.CoroutineContext
@ -25,11 +28,15 @@ class LoadingExceptionHandler(
return
}
Timber.e(exception, "Exception in coroutine")
runBlocking {
withContext(Dispatchers.Main) {
loadingState.value =
LoadingState.Error(
message = errorMessage,
exception = exception,
)
}
}
if (autoToast) {
Toast