feat(android): Admin Quarantine is Reports, with the web's two removals
release / android (push) Canceled after 0s
release / govulncheck (push) Canceled after 0s
release / Build signed APK (push) Canceled after 0s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / web (push) Canceled after 11s
release / integration (push) Canceled after 11s
release / go (push) Canceled after 12s
release / android (push) Canceled after 0s
release / govulncheck (push) Canceled after 0s
release / Build signed APK (push) Canceled after 0s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / web (push) Canceled after 11s
release / integration (push) Canceled after 11s
release / go (push) Canceled after 12s
The Admin card is Reports ("Tracks listeners flagged"). Each report
offers Resolve, Remove the file (the file goes and the track waits for a
good copy, with its likes and plays) and Remove from library (track,
file and history). Both removals now ask first; Delete file used to
delete on the tap.
They stay online-only: each deletes a file for good against a live
queue, so a replay hours later could act on a decision another admin
has since made. Offline they fail with the reason and the row returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-3
@@ -11,9 +11,10 @@ import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Read-through accessor for the admin quarantine queue. No Room cache:
|
||||
* it is an admin's live work list, read fresh each time. Three resolution
|
||||
* actions all delete the row from the queue once the server accepts them.
|
||||
* Read-through accessor for the admin Reports queue. No Room cache: it is an
|
||||
* admin's live work list, read fresh each time, and its actions go straight
|
||||
* to the server, so offline they fail with the reason rather than queueing.
|
||||
* Each action takes the row off the queue once the server accepts it.
|
||||
*/
|
||||
@Singleton
|
||||
class AdminQuarantineRepository @Inject constructor(
|
||||
@@ -25,6 +26,8 @@ class AdminQuarantineRepository @Inject constructor(
|
||||
|
||||
suspend fun resolve(trackId: String) = api.resolve(trackId)
|
||||
|
||||
suspend fun removeFile(trackId: String) = api.removeFile(trackId)
|
||||
|
||||
suspend fun deleteFile(trackId: String) = api.deleteFile(trackId)
|
||||
}
|
||||
|
||||
|
||||
@@ -148,8 +148,8 @@ private fun SectionList(counts: AdminCounts, navController: NavHostController) {
|
||||
item {
|
||||
SectionCard(
|
||||
icon = Lucide.TriangleAlert,
|
||||
title = "Quarantine",
|
||||
subtitle = "Resolve scan failures",
|
||||
title = "Reports",
|
||||
subtitle = "Tracks listeners flagged",
|
||||
count = counts.quarantine,
|
||||
onClick = { navController.navigate(AdminQuarantine) },
|
||||
)
|
||||
|
||||
+76
-6
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.AssistChip
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
@@ -21,7 +22,9 @@ import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -56,7 +59,7 @@ fun AdminQuarantineScreen(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
topBar = {
|
||||
MinstrelTopAppBar(
|
||||
title = "Admin · Quarantine",
|
||||
title = "Admin · Reports",
|
||||
navController = navController,
|
||||
currentRouteName = AdminQuarantine::class.qualifiedName,
|
||||
onBack = { navController.popBackStack() },
|
||||
@@ -71,9 +74,9 @@ fun AdminQuarantineScreen(
|
||||
when (val s = state) {
|
||||
AdminQuarantineUiState.Loading -> LoadingCentered()
|
||||
AdminQuarantineUiState.Empty -> EmptyState(
|
||||
title = "Queue is empty",
|
||||
body = "When users flag tracks as bad rips, wrong tags, or " +
|
||||
"duplicates, their reports get aggregated and surfaced here.",
|
||||
title = "No reports",
|
||||
body = "When listeners flag a track as a bad rip, wrong tags or " +
|
||||
"a duplicate, their reports gather here.",
|
||||
)
|
||||
is AdminQuarantineUiState.Error -> ErrorRetry(
|
||||
title = "Couldn't load queue",
|
||||
@@ -83,6 +86,7 @@ fun AdminQuarantineScreen(
|
||||
is AdminQuarantineUiState.Success -> QueueList(
|
||||
rows = s.rows,
|
||||
onResolve = viewModel::resolve,
|
||||
onRemoveFile = viewModel::removeFile,
|
||||
onDeleteFile = viewModel::deleteFile,
|
||||
)
|
||||
}
|
||||
@@ -90,28 +94,91 @@ fun AdminQuarantineScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/** A confirm asked of the admin before a removal: which one, and of which track. */
|
||||
private enum class Removal { File, Library }
|
||||
|
||||
private data class PendingRemoval(val row: AdminQuarantineItemRef, val kind: Removal)
|
||||
|
||||
@Composable
|
||||
private fun QueueList(
|
||||
rows: List<AdminQuarantineItemRef>,
|
||||
onResolve: (String) -> Unit,
|
||||
onRemoveFile: (String) -> Unit,
|
||||
onDeleteFile: (String) -> Unit,
|
||||
) {
|
||||
var pending by remember { mutableStateOf<PendingRemoval?>(null) }
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(items = rows, key = { it.trackId }) { row ->
|
||||
QuarantineRow(
|
||||
row = row,
|
||||
onResolve = { onResolve(row.trackId) },
|
||||
onDeleteFile = { onDeleteFile(row.trackId) },
|
||||
onRemoveFile = { pending = PendingRemoval(row, Removal.File) },
|
||||
onDeleteFile = { pending = PendingRemoval(row, Removal.Library) },
|
||||
)
|
||||
HorizontalDivider()
|
||||
}
|
||||
}
|
||||
pending?.let { p ->
|
||||
RemovalConfirm(
|
||||
pending = p,
|
||||
onConfirm = {
|
||||
pending = null
|
||||
when (p.kind) {
|
||||
Removal.File -> onRemoveFile(p.row.trackId)
|
||||
Removal.Library -> onDeleteFile(p.row.trackId)
|
||||
}
|
||||
},
|
||||
onDismiss = { pending = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Both removals delete the file, so each asks first. Remove the file keeps the
|
||||
* track waiting for a good copy, with its likes and plays; Remove from library
|
||||
* takes the track and its history too.
|
||||
*/
|
||||
@Composable
|
||||
private fun RemovalConfirm(
|
||||
pending: PendingRemoval,
|
||||
onConfirm: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
) {
|
||||
val title = pending.row.trackTitle
|
||||
val (heading, body, action) = when (pending.kind) {
|
||||
Removal.File -> Triple(
|
||||
"Remove the file?",
|
||||
"Delete the file of \u201c$title\u201d and keep the track. It waits, with its likes " +
|
||||
"and plays, and takes over a good copy when one is in the library. Its reports are cleared.",
|
||||
"Remove the file",
|
||||
)
|
||||
Removal.Library -> Triple(
|
||||
"Remove from library?",
|
||||
"Remove \u201c$title\u201d and its file for good, with its likes, plays and playlist " +
|
||||
"places. To keep the track for a good copy, remove the file instead.",
|
||||
"Remove from library",
|
||||
)
|
||||
}
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text(heading) },
|
||||
text = {
|
||||
Text(
|
||||
text = body,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
},
|
||||
confirmButton = { TextButton(onClick = onConfirm) { Text(action) } },
|
||||
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun QuarantineRow(
|
||||
row: AdminQuarantineItemRef,
|
||||
onResolve: () -> Unit,
|
||||
onRemoveFile: () -> Unit,
|
||||
onDeleteFile: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
@@ -160,6 +227,7 @@ private fun QuarantineRow(
|
||||
}
|
||||
ActionButtons(
|
||||
onResolve = onResolve,
|
||||
onRemoveFile = onRemoveFile,
|
||||
onDeleteFile = onDeleteFile,
|
||||
)
|
||||
}
|
||||
@@ -168,6 +236,7 @@ private fun QuarantineRow(
|
||||
@Composable
|
||||
private fun ActionButtons(
|
||||
onResolve: () -> Unit,
|
||||
onRemoveFile: () -> Unit,
|
||||
onDeleteFile: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
@@ -175,6 +244,7 @@ private fun ActionButtons(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End),
|
||||
) {
|
||||
TextButton(onClick = onResolve) { Text("Resolve") }
|
||||
OutlinedButton(onClick = onDeleteFile) { Text("Delete file") }
|
||||
TextButton(onClick = onDeleteFile) { Text("Remove from library") }
|
||||
OutlinedButton(onClick = onRemoveFile) { Text("Remove the file") }
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,9 +39,8 @@ class AdminQuarantineViewModel @Inject constructor(
|
||||
|
||||
/**
|
||||
* One-shot messages for the screen's snackbar. A failed action has to say
|
||||
* why: the row quietly reappearing reads as a glitch, and for a Delete
|
||||
* file refused by a read-only library it hides the one thing an
|
||||
* admin can fix.
|
||||
* why: the row quietly reappearing reads as a glitch, and for a removal
|
||||
* refused by a read-only library it hides the one thing an admin can fix.
|
||||
*/
|
||||
private val transientMessagesChannel = Channel<String>(Channel.BUFFERED)
|
||||
val transientMessages: Flow<String> = transientMessagesChannel.receiveAsFlow()
|
||||
@@ -81,6 +80,7 @@ class AdminQuarantineViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun resolve(trackId: String) = act(trackId) { repository.resolve(it) }
|
||||
fun removeFile(trackId: String) = act(trackId) { repository.removeFile(it) }
|
||||
fun deleteFile(trackId: String) = act(trackId) { repository.deleteFile(it) }
|
||||
|
||||
private fun act(trackId: String, action: suspend (String) -> Unit) {
|
||||
|
||||
+8
-3
@@ -8,9 +8,11 @@ import retrofit2.http.Path
|
||||
/**
|
||||
* Retrofit interface for `/api/admin/quarantine`.
|
||||
*
|
||||
* Two resolution endpoints:
|
||||
* - `resolve` → admin reviewed, no action taken (clears flags).
|
||||
* - `delete-file` → delete the track's file and row.
|
||||
* Three resolution endpoints:
|
||||
* - `resolve` → admin reviewed, no action taken (clears the reports).
|
||||
* - `remove-file` → delete the track's file and keep the track, which waits
|
||||
* for a good copy with its likes and plays.
|
||||
* - `delete-file` → remove the track from the library, file and history.
|
||||
*/
|
||||
interface AdminQuarantineApi {
|
||||
@GET("api/admin/quarantine")
|
||||
@@ -19,6 +21,9 @@ interface AdminQuarantineApi {
|
||||
@POST("api/admin/quarantine/{trackId}/resolve")
|
||||
suspend fun resolve(@Path("trackId") trackId: String)
|
||||
|
||||
@POST("api/admin/quarantine/{trackId}/remove-file")
|
||||
suspend fun removeFile(@Path("trackId") trackId: String)
|
||||
|
||||
@POST("api/admin/quarantine/{trackId}/delete-file")
|
||||
suspend fun deleteFile(@Path("trackId") trackId: String)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user