feat: challenges, desire sync, how well, memory lane, this or that screens
This commit is contained in:
parent
3f5d7a5cc1
commit
17403b1a75
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue