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 {