mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2722 Membership | Open tier deeplink (#1493)
This commit is contained in:
parent
3104a623c0
commit
e7a37b4299
9 changed files with 95 additions and 2 deletions
|
@ -22,6 +22,7 @@ import com.anytypeio.anytype.domain.payments.SetMembershipEmail
|
|||
import com.anytypeio.anytype.domain.payments.VerifyMembershipEmailCode
|
||||
import com.anytypeio.anytype.core_models.membership.MembershipConstants.EXPLORER_ID
|
||||
import com.anytypeio.anytype.core_models.membership.MembershipConstants.MEMBERSHIP_NAME_MIN_LENGTH
|
||||
import com.anytypeio.anytype.core_models.membership.MembershipConstants.NONE_ID
|
||||
import com.anytypeio.anytype.payments.mapping.toMainView
|
||||
import com.anytypeio.anytype.payments.models.MembershipPurchase
|
||||
import com.anytypeio.anytype.payments.models.TierAnyName
|
||||
|
@ -46,6 +47,8 @@ import kotlinx.coroutines.flow.asSharedFlow
|
|||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.filterIsInstance
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
@ -71,6 +74,8 @@ class MembershipViewModel(
|
|||
|
||||
val navigation = MutableSharedFlow<MembershipNavigation>(0)
|
||||
|
||||
private val _showTierOnStart = MutableStateFlow(NONE_ID)
|
||||
|
||||
/**
|
||||
* Local billing purchase data.
|
||||
*/
|
||||
|
@ -93,6 +98,17 @@ class MembershipViewModel(
|
|||
val anyEmailState = TextFieldState(initialText = "")
|
||||
|
||||
init {
|
||||
Timber.i("MembershipViewModel, init")
|
||||
viewModelScope.launch {
|
||||
combine(
|
||||
_showTierOnStart.filter { it != NONE_ID },
|
||||
viewState.filterIsInstance<MembershipMainState.Default>()
|
||||
) { tierId, _ -> tierId }.collect { tierId ->
|
||||
Timber.d("_showTierOnStart, get new value:$tierId")
|
||||
proceedWithShowingTier(TierId(tierId))
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
val account = getAccount.async(Unit)
|
||||
val accountId = account.getOrNull()?.id.orEmpty()
|
||||
|
@ -131,6 +147,13 @@ class MembershipViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun showTierOnStart(tierId: String?) {
|
||||
val tier = tierId?.toIntOrNull()
|
||||
if (tier != null && tier != NONE_ID) {
|
||||
_showTierOnStart.value = tier
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithUpdatingVisibleTier(mainState: MembershipMainState) {
|
||||
val actualTier = tierState.value
|
||||
if (actualTier is MembershipTierState.Visible && mainState is MembershipMainState.Default) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue