Updated on 2026-08-14

This commit is contained in:
Tangem 2021-07-05 16:54:00 +03:00
commit a0b27a1275
2 changed files with 9 additions and 2 deletions

View file

@ -8,4 +8,10 @@ fun <T> List<T>.containsAny(list: List<T>): Boolean {
list.forEach { if (it == mainItem) return true }
}
return false
}
fun <T> MutableList<T>.removeBy(predicate: (T) -> Boolean): Boolean {
val toRemove = this.filter(predicate)
this.removeAll(toRemove)
return toRemove.isNotEmpty()
}

View file

@ -3,6 +3,7 @@ package com.tangem.tap.domain.configurable.warningMessage
import com.tangem.blockchain.common.Blockchain
import com.tangem.tangem_sdk_new.ui.animation.VoidCallback
import com.tangem.tap.common.extensions.containsAny
import com.tangem.tap.common.extensions.removeBy
import com.tangem.wallet.R
/**
@ -61,12 +62,12 @@ class WarningMessagesManager(
}
fun removeWarnings(origin: WarningMessage.Origin) {
warningsList.removeIf { it.origin == origin }
warningsList.removeBy { it.origin == origin }
sortByPriority()
}
fun removeWarnings(messageRes: Int) {
warningsList.removeIf { it.messageResId == messageRes }
warningsList.removeBy { it.messageResId == messageRes }
}
private fun sortByPriority() {