mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-31 00:29:22 +00:00
fix: stop scrobbling next episode as watched and surface Trakt save errors
Fixes #1196 Fixes #1192 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4eb919df71
commit
0e5ba830d2
3 changed files with 35 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package com.nuvio.app.features.library
|
|||
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.nuvio.app.core.auth.AuthRepository
|
||||
import com.nuvio.app.core.ui.NuvioToastController
|
||||
import com.nuvio.app.core.auth.AuthState
|
||||
import com.nuvio.app.core.network.SupabaseProvider
|
||||
import com.nuvio.app.features.home.PosterShape
|
||||
|
|
@ -40,6 +41,7 @@ import kotlinx.serialization.json.put
|
|||
import nuvio.composeapp.generated.resources.Res
|
||||
import nuvio.composeapp.generated.resources.library_local_tab_title
|
||||
import nuvio.composeapp.generated.resources.library_other
|
||||
import nuvio.composeapp.generated.resources.trakt_lists_update_failed
|
||||
import org.jetbrains.compose.resources.StringResource
|
||||
import org.jetbrains.compose.resources.getString
|
||||
|
||||
|
|
@ -218,7 +220,13 @@ object LibraryRepository {
|
|||
if (isTraktLibrarySourceActive()) {
|
||||
syncScope.launch {
|
||||
runCatching { TraktLibraryRepository.toggleWatchlist(item) }
|
||||
.onFailure { e -> log.e(e) { "Failed to toggle Trakt watchlist" } }
|
||||
.onFailure { e ->
|
||||
log.e(e) { "Failed to toggle Trakt watchlist" }
|
||||
NuvioToastController.show(
|
||||
e.message?.takeIf { it.isNotBlank() }
|
||||
?: getString(Res.string.trakt_lists_update_failed),
|
||||
)
|
||||
}
|
||||
publish()
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -244,8 +244,17 @@ internal fun PlayerScreenRuntime.BindPlayerRuntimeEffects() {
|
|||
BindPlayerMetadataAndSkipEffects()
|
||||
|
||||
DisposableEffect(playbackSession.videoId, activeSourceUrl, activeSourceAudioUrl) {
|
||||
val effectVideoId = playbackSession.videoId
|
||||
val effectSourceUrl = activeSourceUrl
|
||||
val effectSourceAudioUrl = activeSourceAudioUrl
|
||||
onDispose {
|
||||
flushWatchProgress()
|
||||
if (
|
||||
playbackSession.videoId == effectVideoId &&
|
||||
activeSourceUrl == effectSourceUrl &&
|
||||
activeSourceAudioUrl == effectSourceAudioUrl
|
||||
) {
|
||||
flushWatchProgress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,8 +120,23 @@ internal fun PlayerScreenRuntime.emitTraktScrobbleStop(progressPercent: Float? =
|
|||
|
||||
val percent = provided ?: currentPlaybackProgressPercent()
|
||||
val itemSnapshot = currentTraktScrobbleItem
|
||||
val contentTypeSnapshot = contentType ?: parentMetaType
|
||||
val parentMetaIdSnapshot = parentMetaId
|
||||
val videoIdSnapshot = activeVideoId
|
||||
val titleSnapshot = title
|
||||
val seasonNumberSnapshot = activeSeasonNumber
|
||||
val episodeNumberSnapshot = activeEpisodeNumber
|
||||
val episodeTitleSnapshot = activeEpisodeTitle
|
||||
scope.launch(NonCancellable) {
|
||||
val item = itemSnapshot ?: currentTraktScrobbleItem() ?: return@launch
|
||||
val item = itemSnapshot ?: TraktScrobbleRepository.buildItem(
|
||||
contentType = contentTypeSnapshot,
|
||||
parentMetaId = parentMetaIdSnapshot,
|
||||
videoId = videoIdSnapshot,
|
||||
title = titleSnapshot,
|
||||
seasonNumber = seasonNumberSnapshot,
|
||||
episodeNumber = episodeNumberSnapshot,
|
||||
episodeTitle = episodeTitleSnapshot,
|
||||
) ?: return@launch
|
||||
TraktScrobbleRepository.scrobbleStop(
|
||||
item = item,
|
||||
progressPercent = percent,
|
||||
|
|
|
|||
Loading…
Reference in a new issue