mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Fix / tap on accept shows request button instead of start
This commit is contained in:
parent
bf28f14b8b
commit
d1233e8470
@ -34,7 +34,6 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -48,8 +47,6 @@ internal class SasTransportRoomMessage(
|
||||
private val tx: SASVerificationTransaction?
|
||||
) : SasTransport {
|
||||
|
||||
private val listenerExecutor = Executors.newSingleThreadExecutor()
|
||||
|
||||
override fun sendToOther(type: String,
|
||||
verificationInfo: VerificationInfo,
|
||||
nextState: SasVerificationTxState,
|
||||
|
@ -124,7 +124,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
||||
SasVerificationTxState.ShortCodeAccepted,
|
||||
SasVerificationTxState.SendingMac,
|
||||
SasVerificationTxState.MacSent,
|
||||
SasVerificationTxState.Verifying -> {
|
||||
SasVerificationTxState.Verifying -> {
|
||||
showFragment(SASVerificationCodeFragment::class, Bundle().apply {
|
||||
putParcelable(MvRx.KEY_ARG, VerificationArgs(
|
||||
it.otherUserMxItem?.id ?: "",
|
||||
@ -152,7 +152,10 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
||||
} else if (it.pendingRequest == null || !it.pendingRequest.isReady) {
|
||||
// We are waiting for other party to reply with ready
|
||||
showFragment(VerificationRequestFragment::class, Bundle().apply {
|
||||
putParcelable(MvRx.KEY_ARG, VerificationArgs(it.otherUserMxItem?.id ?: ""))
|
||||
putParcelable(MvRx.KEY_ARG, VerificationArgs(
|
||||
it.otherUserMxItem?.id ?: "",
|
||||
it.pendingRequest?.transactionId,
|
||||
it.roomId))
|
||||
})
|
||||
} else if (it.pendingRequest.isReady) {
|
||||
showFragment(VerificationChooseMethodFragment::class, Bundle().apply {
|
||||
|
@ -84,13 +84,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||
|
||||
val userItem = session.getUser(args.otherUserId)
|
||||
|
||||
val sasTx = state.pendingRequest?.transactionId?.let {
|
||||
val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
|
||||
val sasTx = pr?.transactionId?.let {
|
||||
session.getSasVerificationService().getExistingTransaction(args.otherUserId, it)
|
||||
}
|
||||
|
||||
val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId)
|
||||
?.firstOrNull { it.transactionId == args.verificationId }
|
||||
|
||||
return fragment.verificationViewModelFactory.create(VerificationBottomSheetViewState(
|
||||
otherUserMxItem = userItem?.toMatrixItem(),
|
||||
sasTransactionState = sasTx?.state,
|
||||
|
@ -44,18 +44,6 @@ class VerificationRequestViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
withState {
|
||||
val pr = session.getSasVerificationService()
|
||||
.getExistingVerificationRequest(it.matrixItem.id)
|
||||
?.firstOrNull()
|
||||
setState {
|
||||
copy(
|
||||
started = Success(false).takeIf { pr == null }
|
||||
?: Success(true).takeIf { pr?.isReady == true }
|
||||
?: Loading<Boolean>()
|
||||
)
|
||||
}
|
||||
}
|
||||
session.getSasVerificationService().addListener(this)
|
||||
}
|
||||
|
||||
@ -71,11 +59,18 @@ class VerificationRequestViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
override fun initialState(viewModelContext: ViewModelContext): VerificationRequestViewState? {
|
||||
val otherUserId = viewModelContext.args<VerificationBottomSheet.VerificationArgs>().otherUserId
|
||||
val args = viewModelContext.args<VerificationBottomSheet.VerificationArgs>()
|
||||
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
|
||||
|
||||
return session.getUser(otherUserId)?.let {
|
||||
VerificationRequestViewState(matrixItem = it.toMatrixItem())
|
||||
val pr = session.getSasVerificationService()
|
||||
.getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||
return session.getUser(args.otherUserId)?.let {
|
||||
VerificationRequestViewState(
|
||||
started = Success(false).takeIf { pr == null }
|
||||
?: Success(true).takeIf { pr?.isReady == true }
|
||||
?: Loading(),
|
||||
matrixItem = it.toMatrixItem()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user