fix(memorylane): propagate snapshot-listener errors so the screen doesn't hang (F-OBS P3)

observeCapsules swallowed listener errors (return@), so on PERMISSION_DENIED the flow never
emitted or closed and Memory Lane hung on its loading heart forever. Now close(err)s the
flow -> the ViewModel's existing onFailure -> ERROR state with Retry. (Root cause that
masked D-001.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
null 2026-06-25 10:14:17 -05:00
parent 46010508a9
commit 8e08823e83
1 changed files with 6 additions and 1 deletions

View File

@ -67,7 +67,12 @@ class FirestoreCapsuleDataSource @Inject constructor(
val reg = col(coupleId)
.orderBy("createdAt", com.google.firebase.firestore.Query.Direction.DESCENDING)
.addSnapshotListener { snap, err ->
if (err != null || snap == null) return@addSnapshotListener
// Propagate listener failures (e.g. PERMISSION_DENIED) by closing the flow so
// the collector's error handling runs. Previously this swallowed the error
// (`return@`), so the flow never emitted or closed and the Memory Lane screen
// hung on its loading indicator forever (F-OBS).
if (err != null) { close(err); return@addSnapshotListener }
if (snap == null) return@addSnapshotListener
trySend(snap.documents.mapNotNull { doc ->
runCatching { mapToCapsule(doc, coupleId) }.getOrNull()
})