From 72c251ae956f8ea28e027f0c072fc8beabab39f3 Mon Sep 17 00:00:00 2001 From: null Date: Tue, 30 Jun 2026 20:43:14 -0500 Subject: [PATCH] feat(backup): wire opportunistic backup trigger into HomeViewModel.loadHome --- app/src/main/java/app/closer/ui/home/HomeViewModel.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/closer/ui/home/HomeViewModel.kt b/app/src/main/java/app/closer/ui/home/HomeViewModel.kt index 0e4a8ced..bc0dcf76 100644 --- a/app/src/main/java/app/closer/ui/home/HomeViewModel.kt +++ b/app/src/main/java/app/closer/ui/home/HomeViewModel.kt @@ -198,7 +198,8 @@ class HomeViewModel @Inject constructor( private val dailyQuestionResolver: app.closer.domain.usecase.DailyQuestionResolver, private val dateMemoryDataSource: app.closer.data.remote.FirestoreDateMemoryDataSource, private val dateReflectionDataSource: app.closer.data.remote.FirestoreDateReflectionDataSource, - private val answerDataSource: FirestoreAnswerDataSource + private val answerDataSource: FirestoreAnswerDataSource, + private val backupManager: app.closer.data.backup.BackupManager ) : ViewModel() { private val _uiState = MutableStateFlow(HomeUiState()) @@ -273,6 +274,12 @@ class HomeViewModel @Inject constructor( // stops showing a stale "your turn" and never offers a re-answer that the immutable // secure/payload rule would reject (R23). Room-first → a no-op once Room is correct; // the answers observer then recomputes the card. + // Opportunistic E2EE conversation backup (throttled + single-flighted inside the manager; + // no-op without a couple key). Keeps the device-durable backup fresh for restore. + if (couple != null) { + launch { runCatching { backupManager.backupNow() } } + } + val dailyAnswerCoupleId = couple?.id if (uid != null && dailyAnswerCoupleId != null && dailyQuestion != null) { launch {