-
Notifications
You must be signed in to change notification settings - Fork 674
Simplify LinkHandler
& source of truth for Link enablement
#10858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ import com.stripe.android.paymentsheet.state.LinkState | |
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
@@ -17,18 +15,12 @@ import javax.inject.Singleton | |
internal class LinkHandler @Inject constructor( | ||
val linkConfigurationCoordinator: LinkConfigurationCoordinator, | ||
) { | ||
private val _isLinkEnabled = MutableStateFlow<Boolean?>(null) | ||
val isLinkEnabled: StateFlow<Boolean?> = _isLinkEnabled | ||
|
||
private val _linkConfiguration = MutableStateFlow<LinkConfiguration?>(null) | ||
val linkConfiguration: StateFlow<LinkConfiguration?> = _linkConfiguration.asStateFlow() | ||
private val linkConfiguration = MutableStateFlow<LinkConfiguration?>(null) | ||
|
||
fun setupLink(state: LinkState?) { | ||
_isLinkEnabled.value = state != null | ||
|
||
if (state == null) return | ||
|
||
_linkConfiguration.value = state.configuration | ||
linkConfiguration.value = state.configuration | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By doing this, we effectively making this handler a logout manager outside of setting up for eager launch. I think there's an opportunity to move |
||
|
||
suspend fun setupLinkWithEagerLaunch(state: LinkState?): Boolean { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the same condition as
isLinkEnabled
would aftersetupLink
(linkState
!= null)