fix(android): playlist screens and the replay loop meet detekt's limits (#8023)
release / go (push) Successful in 1m49s
release / web (push) Successful in 1m11s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m6s
release / android (push) Successful in 4m19s
release / Build signed APK (push) Successful in 4m44s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 15s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m49s
release / web (push) Successful in 1m11s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m6s
release / android (push) Successful in 4m19s
release / Build signed APK (push) Successful in 4m44s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 15s
release / Verify release artifacts (tag releases only) (push) Skipped
The replay loop's per-row choice moves to replayRow, so the loop has no continue. The playlist detail's top bar and the playlists list's body move into their own composables. ReorderableRow.kt is named for its row, not for ReorderHandles, its parameter type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-5
@@ -145,13 +145,21 @@ class MutationReplayer @Inject constructor(
|
|||||||
// never reaches the server before the create of its list.
|
// never reaches the server before the create of its list.
|
||||||
val waiting = HashSet<String>()
|
val waiting = HashSet<String>()
|
||||||
for (row in rows) {
|
for (row in rows) {
|
||||||
if (row.id in superseded) {
|
replayRow(row, superseded = row.id in superseded, waiting = waiting)
|
||||||
dao.delete(row.id)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends one row, or drops it when a later row has superseded it, or
|
||||||
|
* leaves it queued when an earlier change to the same playlist is still
|
||||||
|
* waiting. A row that has to retry makes its playlist wait in [waiting].
|
||||||
|
*/
|
||||||
|
private suspend fun replayRow(row: CachedMutationEntity, superseded: Boolean, waiting: MutableSet<String>) {
|
||||||
val playlistId = playlistIdOf(row, json)
|
val playlistId = playlistIdOf(row, json)
|
||||||
if (playlistId != null && playlistId in waiting) continue
|
when {
|
||||||
when (outcomeFor(row)) {
|
superseded -> dao.delete(row.id)
|
||||||
|
playlistId != null && playlistId in waiting -> Unit
|
||||||
|
else -> when (outcomeFor(row)) {
|
||||||
Outcome.SENT, Outcome.DROP -> dao.delete(row.id)
|
Outcome.SENT, Outcome.DROP -> dao.delete(row.id)
|
||||||
Outcome.RETRY -> {
|
Outcome.RETRY -> {
|
||||||
dao.recordAttempt(row.id, Clock.System.now())
|
dao.recordAttempt(row.id, Clock.System.now())
|
||||||
|
|||||||
+26
-15
@@ -437,10 +437,35 @@ fun PlaylistDetailScreen(
|
|||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||||
topBar = {
|
topBar = {
|
||||||
|
PlaylistDetailTopBar(state, viewModel, onBack = { navController.popBackStack() })
|
||||||
|
},
|
||||||
|
) { inner ->
|
||||||
|
PullToRefreshScaffold(
|
||||||
|
onRefresh = { viewModel.refresh().join() },
|
||||||
|
modifier = Modifier.fillMaxSize().padding(inner),
|
||||||
|
) {
|
||||||
|
PlaylistDetailContent(
|
||||||
|
state = state,
|
||||||
|
viewModel = viewModel,
|
||||||
|
playerViewModel = playerViewModel,
|
||||||
|
navController = navController,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The title and back arrow, and the owner's menu when the list is theirs to change. */
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
private fun PlaylistDetailTopBar(
|
||||||
|
state: PlaylistDetailUiState,
|
||||||
|
viewModel: PlaylistDetailViewModel,
|
||||||
|
onBack: () -> Unit,
|
||||||
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(currentTitle(state)) },
|
title = { Text(currentTitle(state)) },
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = { navController.popBackStack() }) {
|
IconButton(onClick = onBack) {
|
||||||
Icon(Lucide.ArrowLeft, contentDescription = "Back")
|
Icon(Lucide.ArrowLeft, contentDescription = "Back")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -456,20 +481,6 @@ fun PlaylistDetailScreen(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
|
||||||
) { inner ->
|
|
||||||
PullToRefreshScaffold(
|
|
||||||
onRefresh = { viewModel.refresh().join() },
|
|
||||||
modifier = Modifier.fillMaxSize().padding(inner),
|
|
||||||
) {
|
|
||||||
PlaylistDetailContent(
|
|
||||||
state = state,
|
|
||||||
viewModel = viewModel,
|
|
||||||
playerViewModel = playerViewModel,
|
|
||||||
navController = navController,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
+11
-5
@@ -204,12 +204,20 @@ fun PlaylistsListScreen(
|
|||||||
},
|
},
|
||||||
snackbarHost = { SnackbarHost(snackbar) },
|
snackbarHost = { SnackbarHost(snackbar) },
|
||||||
) { inner ->
|
) { inner ->
|
||||||
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
|
||||||
val offline by viewModel.offline.collectAsStateWithLifecycle()
|
|
||||||
PullToRefreshScaffold(
|
PullToRefreshScaffold(
|
||||||
onRefresh = { viewModel.refresh().join() },
|
onRefresh = { viewModel.refresh().join() },
|
||||||
modifier = Modifier.fillMaxSize().padding(inner),
|
modifier = Modifier.fillMaxSize().padding(inner),
|
||||||
) {
|
) {
|
||||||
|
PlaylistsListBody(viewModel, onOpen = { id -> navController.navigate(PlaylistDetail(id)) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Loading, empty, error, or the grid of playlists. */
|
||||||
|
@Composable
|
||||||
|
private fun PlaylistsListBody(viewModel: PlaylistsListViewModel, onOpen: (String) -> Unit) {
|
||||||
|
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
||||||
|
val offline by viewModel.offline.collectAsStateWithLifecycle()
|
||||||
when (val s = state) {
|
when (val s = state) {
|
||||||
UiState.Loading -> LoadingCentered()
|
UiState.Loading -> LoadingCentered()
|
||||||
UiState.Empty -> EmptyState(
|
UiState.Empty -> EmptyState(
|
||||||
@@ -226,12 +234,10 @@ fun PlaylistsListScreen(
|
|||||||
is UiState.Success -> PlaylistsGrid(
|
is UiState.Success -> PlaylistsGrid(
|
||||||
playlists = s.data,
|
playlists = s.data,
|
||||||
offline = offline,
|
offline = offline,
|
||||||
onPlaylistClick = { id -> navController.navigate(PlaylistDetail(id)) },
|
onPlaylistClick = onOpen,
|
||||||
onPlay = viewModel::playPlaylist,
|
onPlay = viewModel::playPlaylist,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("MatchingDeclarationName") // The file is named for its row; ReorderHandles is the row's parameter type.
|
||||||
|
|
||||||
package com.fabledsword.minstrel.shared.widgets
|
package com.fabledsword.minstrel.shared.widgets
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
|||||||
Reference in New Issue
Block a user