Android: drop a redundant podcast back handler and refresh flag
PodcastSearchScreen registered its own BackHandler inside a SubAppScreen, which already has one. PodcastInfoScreen set a shouldRefresh flag after subscribing to trigger reloadPodcasts(), which subscribeToPodcast (and unsubscribeFromPodcast) already call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e7d55e33f2
commit
b783638908
2 files changed
-12
No files matched your search
-9
@@ -30,19 +30,11 @@ fun PodcastInfoScreen(
|
||||
val subscribedPodcasts by podcastRepository.subscribedPodcasts.collectAsState()
|
||||
val isSubscribed = subscribedPodcasts.containsKey(podcast.id)
|
||||
|
||||
var shouldRefresh by remember { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val snackbar = LocalSnackbarController.current
|
||||
|
||||
LaunchedEffect(Unit) { podcastRepository.reloadPodcasts() }
|
||||
|
||||
LaunchedEffect(shouldRefresh) {
|
||||
if (shouldRefresh) {
|
||||
podcastRepository.reloadPodcasts()
|
||||
shouldRefresh = false
|
||||
}
|
||||
}
|
||||
|
||||
SubAppScreen(title = podcast.title, compactTitle = true, onBack = onBack, modifier = modifier) {
|
||||
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
|
||||
Column(modifier = Modifier.weight(1f).verticalScroll(rememberScrollState())) {
|
||||
@@ -59,7 +51,6 @@ fun PodcastInfoScreen(
|
||||
// explanation (docs/adr/0021).
|
||||
scope.launchReportingFailure(snackbar, TAG, "subscribe") {
|
||||
podcastRepository.subscribeToPodcast(podcast).bind()
|
||||
shouldRefresh = true
|
||||
}
|
||||
} else {
|
||||
val documentId = subscribedPodcasts[podcast.id]?.documentId
|
||||
|
||||
-3
@@ -2,7 +2,6 @@ package com.gregshuflin.synchronicity.podcast.ui
|
||||
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -126,8 +125,6 @@ fun PodcastSearchScreen(
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
BackHandler { onBack() }
|
||||
|
||||
fun performSearch() {
|
||||
if (searchQuery.isBlank()) return
|
||||
scope.launch {
|
||||
|
||||
Reference in new issue
Block a user