mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 15:32:01 +00:00
Refactor MetaDetailsScreen for clarity and efficiency
This commit is contained in:
parent
5fb414ea2f
commit
9affc87efd
1 changed files with 51 additions and 22 deletions
|
|
@ -284,8 +284,35 @@ fun MetaDetailsScreen(
|
||||||
{
|
{
|
||||||
val libraryItem = meta.toLibraryItem(savedAtEpochMs = 0L)
|
val libraryItem = meta.toLibraryItem(savedAtEpochMs = 0L)
|
||||||
if (!isTraktConnected) {
|
if (!isTraktConnected) {
|
||||||
|
// Not on Trakt — toggle local library directly
|
||||||
LibraryRepository.toggleSaved(libraryItem)
|
LibraryRepository.toggleSaved(libraryItem)
|
||||||
} else {
|
} else {
|
||||||
|
// On Trakt — tap directly toggles the watchlist (first list tab)
|
||||||
|
detailsScope.launch {
|
||||||
|
runCatching {
|
||||||
|
val snapshot = LibraryRepository.getMembershipSnapshot(libraryItem)
|
||||||
|
val tabs = LibraryRepository.traktListTabs()
|
||||||
|
// Use the first tab (watchlist) as the quick-save target
|
||||||
|
val watchlistKey = tabs.firstOrNull()?.key
|
||||||
|
if (watchlistKey != null) {
|
||||||
|
val currentlyIn = snapshot[watchlistKey] == true
|
||||||
|
val desired = tabs.associate { tab ->
|
||||||
|
tab.key to if (tab.key == watchlistKey) !currentlyIn else (snapshot[tab.key] == true)
|
||||||
|
}
|
||||||
|
LibraryRepository.applyMembershipChanges(libraryItem, desired)
|
||||||
|
}
|
||||||
|
}.onFailure { e ->
|
||||||
|
// Fallback: toggle via standard path
|
||||||
|
LibraryRepository.toggleSaved(libraryItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val openListPicker = remember(meta, isTraktConnected) {
|
||||||
|
if (!isTraktConnected) null else ({
|
||||||
|
val libraryItem = meta.toLibraryItem(savedAtEpochMs = 0L)
|
||||||
pickerTabs = LibraryRepository.traktListTabs()
|
pickerTabs = LibraryRepository.traktListTabs()
|
||||||
pickerMembership = pickerTabs.associate { it.key to false }
|
pickerMembership = pickerTabs.associate { it.key to false }
|
||||||
pickerPending = true
|
pickerPending = true
|
||||||
|
|
@ -305,8 +332,7 @@ fun MetaDetailsScreen(
|
||||||
pickerPending = false
|
pickerPending = false
|
||||||
}
|
}
|
||||||
Unit
|
Unit
|
||||||
}
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val movieProgress = watchProgressUiState.byVideoId[meta.id]
|
val movieProgress = watchProgressUiState.byVideoId[meta.id]
|
||||||
?.takeUnless { it.isCompleted }
|
?.takeUnless { it.isCompleted }
|
||||||
|
|
@ -634,6 +660,7 @@ fun MetaDetailsScreen(
|
||||||
onPrimaryPlayClick = onPrimaryPlayClick,
|
onPrimaryPlayClick = onPrimaryPlayClick,
|
||||||
onPrimaryPlayLongClick = onPrimaryPlayLongClick,
|
onPrimaryPlayLongClick = onPrimaryPlayLongClick,
|
||||||
onSaveClick = toggleSaved,
|
onSaveClick = toggleSaved,
|
||||||
|
onSaveLongClick = openListPicker,
|
||||||
showManualPlayOption = showManualPlayOption,
|
showManualPlayOption = showManualPlayOption,
|
||||||
preferredEpisodeSeasonNumber = seriesAction?.seasonNumber,
|
preferredEpisodeSeasonNumber = seriesAction?.seasonNumber,
|
||||||
preferredEpisodeNumber = seriesAction?.episodeNumber,
|
preferredEpisodeNumber = seriesAction?.episodeNumber,
|
||||||
|
|
@ -939,6 +966,7 @@ private fun ConfiguredMetaSections(
|
||||||
onPrimaryPlayClick: () -> Unit,
|
onPrimaryPlayClick: () -> Unit,
|
||||||
onPrimaryPlayLongClick: (() -> Unit)?,
|
onPrimaryPlayLongClick: (() -> Unit)?,
|
||||||
onSaveClick: () -> Unit,
|
onSaveClick: () -> Unit,
|
||||||
|
onSaveLongClick: (() -> Unit)?,
|
||||||
showManualPlayOption: Boolean,
|
showManualPlayOption: Boolean,
|
||||||
preferredEpisodeSeasonNumber: Int?,
|
preferredEpisodeSeasonNumber: Int?,
|
||||||
preferredEpisodeNumber: Int?,
|
preferredEpisodeNumber: Int?,
|
||||||
|
|
@ -999,6 +1027,7 @@ private fun ConfiguredMetaSections(
|
||||||
onPlayClick = onPrimaryPlayClick,
|
onPlayClick = onPrimaryPlayClick,
|
||||||
onPlayLongClick = if (showManualPlayOption) onPrimaryPlayLongClick else null,
|
onPlayLongClick = if (showManualPlayOption) onPrimaryPlayLongClick else null,
|
||||||
onSaveClick = onSaveClick,
|
onSaveClick = onSaveClick,
|
||||||
|
onSaveLongClick = onSaveLongClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
MetaScreenSectionKey.OVERVIEW -> {
|
MetaScreenSectionKey.OVERVIEW -> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue