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 3f5d7a5cc1
commit 17403b1a75
5 changed files with 22 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -115,7 +115,8 @@ data class MemoryLaneUiState(
val selectedPrompt: String? = null, val selectedPrompt: String? = null,
val isSaving: Boolean = false, val isSaving: Boolean = false,
val error: String? = null, val error: String? = null,
val hasPremium: Boolean = true val hasPremium: Boolean = true,
val navigateTo: String? = null
) )
@HiltViewModel @HiltViewModel
@ -146,7 +147,7 @@ class MemoryLaneViewModel @Inject constructor(
return@launch return@launch
} }
val couple = coupleRepository.getCoupleForUser(uid) ?: run { 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 return@launch
} }
@ -174,6 +175,8 @@ class MemoryLaneViewModel @Inject constructor(
load() load()
} }
fun onNavigated() = _uiState.update { it.copy(navigateTo = null) }
fun openCreate() = _uiState.update { fun openCreate() = _uiState.update {
it.copy( it.copy(
phase = MemoryLanePhase.CREATE, phase = MemoryLanePhase.CREATE,
@ -247,6 +250,10 @@ fun MemoryLaneScreen(
) { ) {
val state by viewModel.uiState.collectAsState() val state by viewModel.uiState.collectAsState()
LaunchedEffect(state.navigateTo) {
state.navigateTo?.let { onNavigate(it); viewModel.onNavigated() }
}
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()

View File

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