mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-27 15:02:25 +00:00
fix: remove clearing of meta repo
This commit is contained in:
parent
e2868a2060
commit
bd5077bf97
3 changed files with 18 additions and 13 deletions
|
|
@ -562,7 +562,6 @@ private fun MainAppContent(
|
|||
type = route.type,
|
||||
id = route.id,
|
||||
onBack = {
|
||||
MetaDetailsRepository.clear()
|
||||
navController.popBackStack()
|
||||
},
|
||||
onPlay = onPlay,
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ object MetaDetailsRepository {
|
|||
}
|
||||
}
|
||||
|
||||
fun peek(type: String, id: String): MetaDetails? {
|
||||
val requestKey = "$type:$id"
|
||||
return cachedMetaByRequestKey[requestKey]
|
||||
?: _uiState.value.meta?.takeIf { it.type == type && it.id == id }
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
activeRequestKey = null
|
||||
cachedMetaByRequestKey.clear()
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ fun MetaDetailsScreen(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val uiState by MetaDetailsRepository.uiState.collectAsStateWithLifecycle()
|
||||
val displayedMeta = MetaDetailsRepository.peek(type, id)
|
||||
val traktAuthUiState by remember {
|
||||
TraktAuthRepository.ensureLoaded()
|
||||
TraktAuthRepository.uiState
|
||||
|
|
@ -116,8 +117,7 @@ fun MetaDetailsScreen(
|
|||
WatchProgressRepository.uiState
|
||||
}.collectAsStateWithLifecycle()
|
||||
val screenAlpha = remember(type, id) { Animatable(0f) }
|
||||
val requestedMeta = uiState.meta?.takeIf { it.type == type && it.id == id }
|
||||
val needsFreshLoad = requestedMeta == null && !uiState.isLoading
|
||||
val needsFreshLoad = displayedMeta == null && !uiState.isLoading
|
||||
var selectedEpisodeForActions by remember(type, id) { mutableStateOf<MetaVideo?>(null) }
|
||||
val commentsEnabled by remember {
|
||||
TraktCommentsSettings.ensureLoaded()
|
||||
|
|
@ -139,11 +139,11 @@ fun MetaDetailsScreen(
|
|||
|
||||
val shouldShowComments = commentsEnabled &&
|
||||
traktAuthUiState.mode == TraktConnectionMode.CONNECTED &&
|
||||
requestedMeta != null &&
|
||||
requestedMeta.type.lowercase().let { it == "movie" || it == "series" || it == "show" || it == "tv" }
|
||||
displayedMeta != null &&
|
||||
displayedMeta.type.lowercase().let { it == "movie" || it == "series" || it == "show" || it == "tv" }
|
||||
|
||||
LaunchedEffect(requestedMeta?.id, shouldShowComments) {
|
||||
if (!shouldShowComments || requestedMeta == null) {
|
||||
LaunchedEffect(displayedMeta?.id, shouldShowComments) {
|
||||
if (!shouldShowComments || displayedMeta == null) {
|
||||
comments = emptyList()
|
||||
commentsCurrentPage = 0
|
||||
commentsPageCount = 0
|
||||
|
|
@ -153,7 +153,7 @@ fun MetaDetailsScreen(
|
|||
isCommentsLoading = true
|
||||
commentsError = null
|
||||
try {
|
||||
val result = TraktCommentsRepository.getCommentsPage(requestedMeta, page = 1)
|
||||
val result = TraktCommentsRepository.getCommentsPage(displayedMeta, page = 1)
|
||||
comments = result.items
|
||||
commentsCurrentPage = result.currentPage
|
||||
commentsPageCount = result.pageCount
|
||||
|
|
@ -183,14 +183,14 @@ fun MetaDetailsScreen(
|
|||
.background(MaterialTheme.colorScheme.background),
|
||||
) {
|
||||
when {
|
||||
uiState.isLoading || (uiState.meta != null && requestedMeta == null) -> {
|
||||
displayedMeta == null && uiState.isLoading -> {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
uiState.errorMessage != null -> {
|
||||
displayedMeta == null && uiState.errorMessage != null -> {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.align(Alignment.Center)
|
||||
|
|
@ -211,8 +211,8 @@ fun MetaDetailsScreen(
|
|||
}
|
||||
}
|
||||
|
||||
requestedMeta != null -> {
|
||||
val meta = requestedMeta
|
||||
displayedMeta != null -> {
|
||||
val meta = displayedMeta
|
||||
val todayIsoDate = CurrentDateProvider.todayIsoDate()
|
||||
val isSaved = remember(libraryUiState.items, meta.id) {
|
||||
libraryUiState.items.any { it.id == meta.id }
|
||||
|
|
@ -754,7 +754,7 @@ fun MetaDetailsScreen(
|
|||
}
|
||||
}
|
||||
|
||||
if (requestedMeta == null) {
|
||||
if (displayedMeta == null) {
|
||||
NuvioBackButton(
|
||||
onClick = onBack,
|
||||
modifier = Modifier.padding(
|
||||
|
|
|
|||
Loading…
Reference in a new issue