Android: say a document is gone instead of spinning forever on its detail screen (BUG5)

DocumentDetailScreen treated "documents().get returned null" and "still
loading" alike, so a document deleted or purged (here, or by a purge
from another node) left the screen on a spinner, and a failed read did the
same after only logging. It is now tri-state: loading, gone — which says
copy::documents::GONE, exported on DocumentCopy — or loaded; a failed read
shows the error like the detail rows' failure already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-09-28 11:11:10 -07:00
1 parent bb8fa8ca5f
commit a783c93a5d
3 files changed
+20 -4

No files matched your search

@@ -21,7 +21,6 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.gregshuflin.synchronicity.NativeLib
import com.gregshuflin.synchronicity.getOrLog
import com.gregshuflin.synchronicity.jobs.JobActivity
import com.gregshuflin.synchronicity.jobs.JobControl
import com.gregshuflin.synchronicity.jobs.JobKinds
@@ -93,6 +92,8 @@ fun DocumentDetailScreen(documentId: String, onBack: () -> Unit, modifier: Modif
var blobRefs by remember { mutableStateOf<List<DocumentBlobRefItem>>(emptyList()) }
var nodeStatuses by remember { mutableStateOf<List<DocumentNodeStatusItem>>(emptyList()) }
var error by remember { mutableStateOf<String?>(null) }
// The document no longer exists here — deleted or purged — as opposed to still loading.
var gone by remember { mutableStateOf(false) }
// Descendant count shown on the Sync card so users know syncing recurses
// into children; null while still loading.
var descendantCount by remember { mutableStateOf<UInt?>(null) }
@@ -138,9 +139,16 @@ fun DocumentDetailScreen(documentId: String, onBack: () -> Unit, modifier: Modif
LaunchedEffect(Unit) { syncOverrideOptions = getDocumentSyncOverrideOptions() }
LaunchedEffect(documentId, reloadKey) {
document =
withContext(Dispatchers.IO) { nativeLib.ffi { documents().get(documentId) } }
.getOrLog(TAG, "Failed to load document $documentId")
withContext(Dispatchers.IO) { nativeLib.ffi { documents().get(documentId) } }
.onSuccess {
document = it
gone = it == null
}
.onFailure {
Log.e(TAG, "Failed to load document $documentId", it)
error = it.userMessage
}
if (document == null) return@LaunchedEffect
withContext(Dispatchers.IO) {
nativeLib.ffi {
val docs = documents()
@@ -379,6 +387,7 @@ fun DocumentDetailScreen(documentId: String, onBack: () -> Unit, modifier: Modif
error != null -> {
CenteredMessage("Error: $error", color = MaterialTheme.colorScheme.error)
}
gone -> CenteredMessage(SharedCopy.documents.gone)
loadedDocument == null -> {
CenteredLoading()
}
+6
View File
@@ -1679,6 +1679,12 @@ pub mod documents {
}
}
/// A document screen whose document no longer exists here — deleted or
/// purged, on this node or by a purge that reached it from another. A
/// state to say, not a spinner to leave running.
pub const GONE: &str =
"This document is gone: it was deleted or purged, here or on another node.";
pub const PURGE_TITLE: &str = "Purge this document?";
pub const PURGE_ACTION: &str = "Purge";
+1
View File
@@ -214,6 +214,7 @@ copy_record! {
delete_locally_title: DELETE_LOCALLY_TITLE,
changed_elsewhere: CHANGED_ELSEWHERE,
preserve_directory_structure: import_directory::PRESERVE_STRUCTURE,
gone: GONE,
}
}