feat: block re-upload of files already on server + visible upload progress

- Hide upload button when file is in uploadedNames (already on server)
- UploadWorker still guards via /status already_uploaded check
- Indeterminate progress bar during Hashing/Checking phases
- Upload label always shows percentage
This commit is contained in:
Mathieu Moran
2026-08-12 18:08:26 -04:00
parent 2012370cef
commit 30b919bc03
@@ -120,12 +120,21 @@ fun DownloadsScreen(
} }
if (!dl.done) { if (!dl.done) {
Spacer(Modifier.height(8.dp)) Spacer(Modifier.height(8.dp))
LinearProgressIndicator( if (dl.progress > 0) {
progress = { dl.progress / 100f }, LinearProgressIndicator(
modifier = Modifier.fillMaxWidth().height(6.dp).clip(RoundedCornerShape(3.dp)), progress = { dl.progress / 100f },
color = MaterialTheme.colorScheme.tertiary, modifier = Modifier.fillMaxWidth().height(6.dp).clip(RoundedCornerShape(3.dp)),
trackColor = MaterialTheme.colorScheme.surfaceVariant, color = MaterialTheme.colorScheme.tertiary,
) trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
} else {
// Indeterminate bar so hashing/checking phases show visible activity
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth().height(6.dp).clip(RoundedCornerShape(3.dp)),
color = MaterialTheme.colorScheme.tertiary,
trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
}
} }
} }
} }
@@ -228,7 +237,7 @@ fun DownloadsScreen(
if (isDeleting) { if (isDeleting) {
CircularProgressIndicator(modifier = Modifier.size(20.dp), strokeWidth = 2.dp, color = MaterialTheme.colorScheme.error) CircularProgressIndicator(modifier = Modifier.size(20.dp), strokeWidth = 2.dp, color = MaterialTheme.colorScheme.error)
} else { } else {
if (credentialsConfigured) { if (credentialsConfigured && file.name !in uploadedNames) {
IconButton(onClick = { onUpload(file) }) { IconButton(onClick = { onUpload(file) }) {
Icon(Icons.Filled.CloudUpload, "Upload", tint = MaterialTheme.colorScheme.tertiary) Icon(Icons.Filled.CloudUpload, "Upload", tint = MaterialTheme.colorScheme.tertiary)
} }
@@ -248,7 +257,7 @@ fun DownloadsScreen(
private fun uploadLabel(dl: ActiveDownload): String { private fun uploadLabel(dl: ActiveDownload): String {
val pct = "${dl.progress}%" val pct = "${dl.progress}%"
val status = dl.status ?: return pct val status = dl.status ?: return pct
return if (dl.progress > 0) "$status · $pct" else status return "$status · $pct"
} }
private fun formatSize(bytes: Long): String = when { private fun formatSize(bytes: Long): String = when {