diff --git a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt index 80f86954d..b5bc119f2 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt @@ -50,7 +50,6 @@ import com.github.damontecres.wholphin.services.hilt.AuthOkHttpClient import com.github.damontecres.wholphin.services.tvprovider.TvProviderSchedulerService import com.github.damontecres.wholphin.ui.CoilConfig import com.github.damontecres.wholphin.ui.LocalImageUrlService -import com.github.damontecres.wholphin.ui.collectLatestIn import com.github.damontecres.wholphin.ui.components.LoadingPage import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds import com.github.damontecres.wholphin.ui.launchDefault @@ -169,16 +168,19 @@ class MainActivity : AppCompatActivity() { navigationManager.backStack = NavBackStack(startDestination) } - viewModel.serverRepository.currentUserFlow.collectLatestIn(lifecycleScope) { user -> - if (user?.hasPin == true) { - window?.setFlags( - WindowManager.LayoutParams.FLAG_SECURE, - WindowManager.LayoutParams.FLAG_SECURE, - ) - } else { - window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) - } - } + viewModel.serverRepository.currentUserFlow + .onEach { user -> + withContext(Dispatchers.Main) { + if (user?.hasPin == true) { + window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) + } else { + window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) + } + } + }.catch { ex -> + Timber.e(ex, "Error with settings flag secure") + }.launchIn(lifecycleScope) + screensaverService.keepScreenOn .onEach { keepScreenOn -> Timber.v("keepScreenOn: %s", keepScreenOn) diff --git a/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt b/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt index 7a0dcc9b2..4b03c6767 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/services/HomeSettingsService.kt @@ -553,8 +553,10 @@ class HomeSettingsService ): StringProvider = try { api.userLibraryApi - .getItem(itemId = itemId) - .content.name + .getItem( + userId = serverRepository.currentUser?.id, + itemId = itemId, + ).content.name ?.let { if (stringRes == null) { StringStringProvider(it) @@ -876,8 +878,15 @@ class HomeSettingsService fields = DefaultItemFields, ) + // Not using getItemName because we want to throw the 404 val title = - getItemName(null, row.parentId, ResStringProvider(R.string.collection)) + api.userLibraryApi + .getItem( + userId = serverRepository.currentUser?.id, + itemId = row.parentId, + ).content.name + ?.let { StringStringProvider(it) } + ?: ResStringProvider(R.string.collection) if (usePaging) { ApiRequestPager( api,