Skip to content

Commit

Permalink
Fix the onboarding flow getting stuck in some cases (#3778)
Browse files Browse the repository at this point in the history
This was caused by several `DefaultFtueService` instances being created and only the latest one receiving new state updates while the `LoggedInFlowNode` which decides the navigation was stuck subscribed to the initial one. `DefaultFtueService` has now been marked as s singleton to fix this.
  • Loading branch information
jmartinesp authored Oct 31, 2024
1 parent a772f00 commit 057ef38
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.element.android.features.ftue.api.state.FtueService
import io.element.android.features.ftue.api.state.FtueState
import io.element.android.features.lockscreen.api.LockScreenService
import io.element.android.libraries.di.SessionScope
import io.element.android.libraries.di.SingleIn
import io.element.android.libraries.di.annotations.SessionCoroutineScope
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus
Expand All @@ -32,12 +33,12 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.timeout
import kotlinx.coroutines.runBlocking
import timber.log.Timber
import javax.inject.Inject
import kotlin.time.Duration.Companion.seconds

@ContributesBinding(SessionScope::class)
@SingleIn(SessionScope::class)
class DefaultFtueService @Inject constructor(
private val sdkVersionProvider: BuildVersionSdkIntProvider,
@SessionCoroutineScope sessionCoroutineScope: CoroutineScope,
Expand Down Expand Up @@ -130,7 +131,7 @@ class DefaultFtueService @Inject constructor(
private suspend fun shouldAskNotificationPermissions(): Boolean {
return if (sdkVersionProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) {
val permission = Manifest.permission.POST_NOTIFICATIONS
val isPermissionDenied = runBlocking { permissionStateProvider.isPermissionDenied(permission).first() }
val isPermissionDenied = permissionStateProvider.isPermissionDenied(permission).first()
val isPermissionGranted = permissionStateProvider.isPermissionGranted(permission)
!isPermissionGranted && !isPermissionDenied
} else {
Expand Down

0 comments on commit 057ef38

Please sign in to comment.