mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-18 16:01:44 +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.consumeAutoPlay()
|
||||||
|
StreamsRepository.cancelLoading()
|
||||||
navController.navigate(PlayerRoute(launchId = launchId)) {
|
navController.navigate(PlayerRoute(launchId = launchId)) {
|
||||||
popUpTo<StreamRoute> { inclusive = true }
|
popUpTo<StreamRoute> { inclusive = true }
|
||||||
}
|
}
|
||||||
|
|
@ -1405,6 +1406,7 @@ private fun MainAppContent(
|
||||||
initialProgressFraction = resolvedResumeProgressFraction,
|
initialProgressFraction = resolvedResumeProgressFraction,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
StreamsRepository.cancelLoading()
|
||||||
navController.navigate(
|
navController.navigate(
|
||||||
PlayerRoute(launchId = launchId)
|
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() {
|
fun clear() {
|
||||||
activeJob?.cancel()
|
activeJob?.cancel()
|
||||||
|
activeJob = null
|
||||||
activeRequestKey = null
|
activeRequestKey = null
|
||||||
_uiState.value = StreamsUiState()
|
_uiState.value = StreamsUiState()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue