diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 9f8a3e9cb..a38669b52 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -777,6 +777,10 @@ afterEvaluate { } } +configurations.matching { it.name == "iosMainImplementation" }.configureEach { + project.dependencies.add(name, libs.ktor.client.darwin) +} + dependencies { coreLibraryDesugaring(libs.desugar.jdk.libs) debugImplementation(libs.compose.uiTooling) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/library/LibraryRepository.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/library/LibraryRepository.kt index 906c59e25..c4c86bb08 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/library/LibraryRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/library/LibraryRepository.kt @@ -16,11 +16,6 @@ import com.nuvio.app.features.trakt.effectiveLibrarySourceMode as resolveEffecti import com.nuvio.app.features.trakt.shouldUseTraktLibrary import io.github.jan.supabase.postgrest.postgrest import io.github.jan.supabase.postgrest.rpc -import kotlinx.coroutines.runBlocking -import nuvio.composeapp.generated.resources.Res -import nuvio.composeapp.generated.resources.library_local_tab_title -import nuvio.composeapp.generated.resources.library_other -import org.jetbrains.compose.resources.getString import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -33,6 +28,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString @@ -41,6 +37,11 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.encodeToJsonElement 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 org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.getString @Serializable private data class StoredLibraryPayload( @@ -476,11 +477,16 @@ object LibraryRepository { } internal const val LOCAL_LIBRARY_LIST_KEY = "local" +private const val DEFAULT_LOCAL_LIBRARY_TAB_TITLE = "Nuvio Library" +private const val DEFAULT_LIBRARY_OTHER_TITLE = "Other" internal fun localLibraryListTab(): TraktListTab = TraktListTab( key = LOCAL_LIBRARY_LIST_KEY, - title = runBlocking { getString(Res.string.library_local_tab_title) }, + title = localizedStringOrDefault( + resource = Res.string.library_local_tab_title, + fallback = DEFAULT_LOCAL_LIBRARY_TAB_TITLE, + ), type = TraktListType.WATCHLIST, ) @@ -552,7 +558,7 @@ private fun PosterShape.toSyncName(): String = internal fun String.toLibraryDisplayTitle(): String { val normalized = trim() - if (normalized.isBlank()) return runBlocking { getString(Res.string.library_other) } + if (normalized.isBlank()) return localizedLibraryOtherTitle() return normalized .split('-', '_', ' ') @@ -560,5 +566,15 @@ internal fun String.toLibraryDisplayTitle(): String { .joinToString(" ") { token -> token.lowercase().replaceFirstChar { char -> char.uppercase() } } - .ifBlank { runBlocking { getString(Res.string.library_other) } } + .ifBlank { localizedLibraryOtherTitle() } } + +private fun localizedLibraryOtherTitle(): String = + localizedStringOrDefault( + resource = Res.string.library_other, + fallback = DEFAULT_LIBRARY_OTHER_TITLE, + ) + +private fun localizedStringOrDefault(resource: StringResource, fallback: String): String = + runCatching { runBlocking { getString(resource) } } + .getOrDefault(fallback) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamAutoPlaySelector.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamAutoPlaySelector.kt index 881f90004..2fde7b9a2 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamAutoPlaySelector.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamAutoPlaySelector.kt @@ -198,7 +198,12 @@ object StreamAutoPlaySelector { activeResolverProviderId: String?, ): Boolean = playableDirectUrl != null || - (AppFeaturePolicy.p2pEnabled && needsLocalDebridResolve && p2pInfoHash != null) || + ( + AppFeaturePolicy.p2pEnabled && + needsLocalDebridResolve && + p2pInfoHash != null && + !isPendingDebridAutoPlay(debridEnabled, activeResolverProviderId) + ) || (debridEnabled && isAddonDebridCandidate && isReadyDebridAutoPlay(activeResolverProviderId)) private fun StreamItem.isReadyDebridAutoPlay(activeResolverProviderId: String?): Boolean =