feat: challenges, desire sync, how well, memory lane, this or that screens

This commit is contained in:
null 2026-06-22 21:24:02 -05:00
parent 1905938c80
commit 504dd8de4c
5 changed files with 22 additions and 9 deletions

View File

@ -112,7 +112,7 @@ class ConnectionChallengesViewModel @Inject constructor(
return@launch
}
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
_uiState.update { it.copy(phase = ChallengesPhase.PICK) }
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
return@launch
}
val partnerId = couple.userIds.firstOrNull { it != uid } ?: uid

View File

@ -145,8 +145,10 @@ class DesireSyncViewModel @Inject constructor(
}
val uid = gameSessionManager.currentUserId
?: return@launch fail("You need to be signed in to play.")
val couple = gameSessionManager.getCoupleForUser(uid)
?: return@launch fail("Pair with your partner to play together.")
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
return@launch
}
userId = uid
coupleId = couple.id

View File

@ -175,8 +175,10 @@ class HowWellViewModel @Inject constructor(
viewModelScope.launch {
val uid = gameSessionManager.currentUserId
?: return@launch fail("You need to be signed in to play.")
val couple = gameSessionManager.getCoupleForUser(uid)
?: return@launch fail("Pair with your partner to play together.")
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
return@launch
}
userId = uid
coupleId = couple.id
partnerId = couple.userIds.firstOrNull { it != uid }

View File

@ -115,7 +115,8 @@ data class MemoryLaneUiState(
val selectedPrompt: String? = null,
val isSaving: Boolean = false,
val error: String? = null,
val hasPremium: Boolean = true
val hasPremium: Boolean = true,
val navigateTo: String? = null
)
@HiltViewModel
@ -146,7 +147,7 @@ class MemoryLaneViewModel @Inject constructor(
return@launch
}
val couple = coupleRepository.getCoupleForUser(uid) ?: run {
_uiState.update { it.copy(phase = MemoryLanePhase.ERROR, error = "Link up with a partner to start creating capsules.") }
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
return@launch
}
@ -174,6 +175,8 @@ class MemoryLaneViewModel @Inject constructor(
load()
}
fun onNavigated() = _uiState.update { it.copy(navigateTo = null) }
fun openCreate() = _uiState.update {
it.copy(
phase = MemoryLanePhase.CREATE,
@ -247,6 +250,10 @@ fun MemoryLaneScreen(
) {
val state by viewModel.uiState.collectAsState()
LaunchedEffect(state.navigateTo) {
state.navigateTo?.let { onNavigate(it); viewModel.onNavigated() }
}
Box(
modifier = Modifier
.fillMaxSize()

View File

@ -170,8 +170,10 @@ class ThisOrThatViewModel @Inject constructor(
viewModelScope.launch {
val uid = gameSessionManager.currentUserId
?: return@launch fail("You need to be signed in to play.")
val couple = gameSessionManager.getCoupleForUser(uid)
?: return@launch fail("Pair with your partner to play together.")
val couple = gameSessionManager.getCoupleForUser(uid) ?: run {
_uiState.update { it.copy(navigateTo = AppRoute.CREATE_INVITE) }
return@launch
}
userId = uid
coupleId = couple.id