Merge pull request #612 from poanetwork/frg-use-indexed-token-balances-in-dropdown
Use indexed token balances in the address page balances dropdownpull/630/head
commit
867ed7235e
@ -1,20 +1,20 @@ |
||||
defmodule BlockScoutWeb.AddressTokenBalanceView do |
||||
use BlockScoutWeb, :view |
||||
|
||||
def tokens_count_title(tokens) do |
||||
ngettext("%{count} token", "%{count} tokens", Enum.count(tokens)) |
||||
def tokens_count_title(token_balances) do |
||||
ngettext("%{count} token", "%{count} tokens", Enum.count(token_balances)) |
||||
end |
||||
|
||||
def filter_by_type(tokens, type) do |
||||
Enum.filter(tokens, &(&1.type == type)) |
||||
def filter_by_type(token_balances, type) do |
||||
Enum.filter(token_balances, &(&1.token.type == type)) |
||||
end |
||||
|
||||
@doc """ |
||||
Sorts the given list of tokens in alphabetically order considering nil values in the bottom of |
||||
the list. |
||||
""" |
||||
def sort_by_name(tokens) do |
||||
{unnamed, named} = Enum.split_with(tokens, &is_nil(&1.name)) |
||||
Enum.sort_by(named, &String.downcase(&1.name)) ++ unnamed |
||||
def sort_by_name(token_balances) do |
||||
{unnamed, named} = Enum.split_with(token_balances, &is_nil(&1.token.name)) |
||||
Enum.sort_by(named, &String.downcase(&1.token.name)) ++ unnamed |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue