Cancel verification alerts when adding the incoming request alert and when starting the process

This commit is contained in:
Maxime NATUREL 2022-12-08 14:40:17 +01:00
parent df55c84167
commit 63bde230a3
1 changed files with 10 additions and 5 deletions

View File

@ -128,12 +128,9 @@ class IncomingVerificationRequestHandler @Inject constructor(
// For incoming request we should prompt (if not in activity where this request apply) // For incoming request we should prompt (if not in activity where this request apply)
if (pr.isIncoming) { if (pr.isIncoming) {
// if it's a self verification for my devices, we can discard the review login alert // if it's a self verification for my devices, we can discard the review login alert
// if not this request will be underneath and not visible by the user... // if not, this request will be underneath and not visible by the user...
// it will re-appear later // it will re-appear later
if (pr.otherUserId == session?.myUserId) { cancelAnyVerifySessionAlerts(pr)
popupAlertManager.cancelAlert(PopupAlertManager.REVIEW_LOGIN_UID)
popupAlertManager.cancelAlert(PopupAlertManager.VERIFY_SESSION_UID)
}
val user = session.getUserOrDefault(pr.otherUserId).toMatrixItem() val user = session.getUserOrDefault(pr.otherUserId).toMatrixItem()
val name = user.getBestName() val name = user.getBestName()
val description = if (name == pr.otherUserId) { val description = if (name == pr.otherUserId) {
@ -159,6 +156,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
.apply { .apply {
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer.get()) viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer.get())
contentAction = Runnable { contentAction = Runnable {
cancelAnyVerifySessionAlerts(pr)
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { (weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let {
val roomId = pr.roomId val roomId = pr.roomId
if (roomId.isNullOrBlank()) { if (roomId.isNullOrBlank()) {
@ -188,6 +186,13 @@ class IncomingVerificationRequestHandler @Inject constructor(
} }
} }
private fun cancelAnyVerifySessionAlerts(pr: PendingVerificationRequest) {
if (pr.otherUserId == session?.myUserId) {
popupAlertManager.cancelAlert(PopupAlertManager.REVIEW_LOGIN_UID)
popupAlertManager.cancelAlert(PopupAlertManager.VERIFY_SESSION_UID)
}
}
override fun verificationRequestUpdated(pr: PendingVerificationRequest) { override fun verificationRequestUpdated(pr: PendingVerificationRequest) {
// If an incoming request is readied (by another device?) we should discard the alert // If an incoming request is readied (by another device?) we should discard the alert
if (pr.isIncoming && (pr.isReady || pr.handledByOtherSession || pr.cancelConclusion != null)) { if (pr.isIncoming && (pr.isReady || pr.handledByOtherSession || pr.cancelConclusion != null)) {