fix: handle partner_active_session error in SpinWheelViewModel, navigate to waiting screen
This commit is contained in:
parent
1b344e7220
commit
debc6aed02
|
|
@ -119,16 +119,23 @@ class SpinWheelViewModel @Inject constructor(
|
|||
gameType = "wheel",
|
||||
categoryId = categoryId,
|
||||
questionIds = questionIds
|
||||
).getOrNull()
|
||||
}.getOrNull()
|
||||
)
|
||||
}.getOrElse { Result.failure(it) }
|
||||
|
||||
if (startResult == null) {
|
||||
_uiState.update { it.copy(error = "Could not start session") }
|
||||
return@launch
|
||||
when {
|
||||
startResult.isSuccess -> {
|
||||
val sessionId = startResult.getOrThrow()
|
||||
sessionStore.sessionId = sessionId
|
||||
_uiState.update { it.copy(navigateTo = AppRoute.wheelSession(sessionId)) }
|
||||
}
|
||||
startResult.exceptionOrNull()?.message?.startsWith("partner_active_session|") == true -> {
|
||||
_uiState.update { it.copy(navigateTo = AppRoute.WAITING_FOR_PARTNER) }
|
||||
}
|
||||
else -> {
|
||||
Log.w(TAG, "Could not start wheel session", startResult.exceptionOrNull())
|
||||
_uiState.update { it.copy(error = "Could not start session") }
|
||||
}
|
||||
}
|
||||
|
||||
sessionStore.sessionId = startResult
|
||||
_uiState.update { it.copy(navigateTo = AppRoute.wheelSession(startResult)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue