-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix/tinder gov bug fix #1658
Fix/tinder gov bug fix #1658
Conversation
Feature/tindergov banner
…yout Feature/tindergov cards layout
Tinder gov logic
|
||
return asset.freeInPlanks >= votingPower.amount | ||
return if (asset.freeInPlanks >= votingPower.amount) { |
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.
We shouldnt dublicate the fact that "free balance is used for voting". We can extract it to extension like Asset.availableToVote
. Otherwise it becomes error prone for future changes
@@ -140,16 +143,23 @@ class TinderGovBasketViewModel( | |||
val availableToVoteReferenda = availableToVoteReferendaFlow.first() | |||
|
|||
val removedReferenda = basket.filter { availableToVoteReferenda.contains(it.referendumId).not() } | |||
.filter { interactor.basketItemValidForVote(it) } |
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 is strange. Why does removed referenda is filtered list is by the validity? Even if its correct (e.g. if you aim to filter out "invalid by voting power" referenda and only show number "invalid by status" this code doesnt make sense for the external reader who might not know the context
if (removedReferenda.isNotEmpty()) { | ||
interactor.removeBasketItems(removedReferenda) | ||
|
||
itemsWasRemovedFromBasketAction.awaitAction() | ||
itemsWasRemovedFromBasketAction.awaitAction(getFormattedAmountAvailableToVote()) | ||
|
||
closeScreenIfBasketIsEmpty() | ||
} |
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.
So we wont attempt to close the screen if there was some "invalid valid" referenda that was removed?
...ndation/nova/feature_governance_impl/presentation/tindergov/cards/TinderGovCardsViewModel.kt
Show resolved
Hide resolved
fun <T> List<T>.countBy(predicate: (T) -> Boolean): Int { | ||
return filter { predicate(it) }.size | ||
} |
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.
Irrc there was count {}
extension in stdlib already? Also countring by performing filtering is a bit unefficient as we have to allocate an extra list
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.
Yes We has this extension, thank you. I'll change it
VoteTinderGovValidationFailure.AlreadyDelegatingVotes -> handleAlreadyDelegatingVotes(resourceManager) | ||
|
||
is VoteTinderGovValidationFailure.AmountIsTooBig -> { | ||
handleAmountIsTooBig(resourceManager, failure) |
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 line looks redundant?
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.
Right, thank you
#8695mxtfw
#8695mwrd4