mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
fix: add cancelLoading method to StreamsRepository
This commit is contained in:
parent
8a58fabfdd
commit
5e65881716
2 changed files with 26 additions and 0 deletions
|
|
@ -1327,6 +1327,7 @@ private fun MainAppContent(
|
|||
)
|
||||
)
|
||||
StreamsRepository.consumeAutoPlay()
|
||||
StreamsRepository.cancelLoading()
|
||||
navController.navigate(PlayerRoute(launchId = launchId)) {
|
||||
popUpTo<StreamRoute> { inclusive = true }
|
||||
}
|
||||
|
|
@ -1405,6 +1406,7 @@ private fun MainAppContent(
|
|||
initialProgressFraction = resolvedResumeProgressFraction,
|
||||
)
|
||||
)
|
||||
StreamsRepository.cancelLoading()
|
||||
navController.navigate(
|
||||
PlayerRoute(launchId = launchId)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -424,8 +424,32 @@ object StreamsRepository {
|
|||
}
|
||||
}
|
||||
|
||||
fun cancelLoading() {
|
||||
activeJob?.cancel()
|
||||
activeJob = null
|
||||
_uiState.update { current ->
|
||||
if (!current.isAnyLoading && current.groups.none { it.isLoading }) {
|
||||
current
|
||||
} else {
|
||||
val updatedGroups = current.groups.map { group ->
|
||||
if (group.isLoading) group.copy(isLoading = false) else group
|
||||
}
|
||||
current.copy(
|
||||
groups = updatedGroups,
|
||||
isAnyLoading = false,
|
||||
emptyStateReason = if (updatedGroups.isEmpty()) {
|
||||
current.emptyStateReason
|
||||
} else {
|
||||
updatedGroups.toEmptyStateReason(anyLoading = false)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
activeJob?.cancel()
|
||||
activeJob = null
|
||||
activeRequestKey = null
|
||||
_uiState.value = StreamsUiState()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue