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 |
defmodule BlockScoutWeb.AddressTokenBalanceView do |
||||||
use BlockScoutWeb, :view |
use BlockScoutWeb, :view |
||||||
|
|
||||||
def tokens_count_title(tokens) do |
def tokens_count_title(token_balances) do |
||||||
ngettext("%{count} token", "%{count} tokens", Enum.count(tokens)) |
ngettext("%{count} token", "%{count} tokens", Enum.count(token_balances)) |
||||||
end |
end |
||||||
|
|
||||||
def filter_by_type(tokens, type) do |
def filter_by_type(token_balances, type) do |
||||||
Enum.filter(tokens, &(&1.type == type)) |
Enum.filter(token_balances, &(&1.token.type == type)) |
||||||
end |
end |
||||||
|
|
||||||
@doc """ |
@doc """ |
||||||
Sorts the given list of tokens in alphabetically order considering nil values in the bottom of |
Sorts the given list of tokens in alphabetically order considering nil values in the bottom of |
||||||
the list. |
the list. |
||||||
""" |
""" |
||||||
def sort_by_name(tokens) do |
def sort_by_name(token_balances) do |
||||||
{unnamed, named} = Enum.split_with(tokens, &is_nil(&1.name)) |
{unnamed, named} = Enum.split_with(token_balances, &is_nil(&1.token.name)) |
||||||
Enum.sort_by(named, &String.downcase(&1.name)) ++ unnamed |
Enum.sort_by(named, &String.downcase(&1.token.name)) ++ unnamed |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue