|
|
|
@ -7,50 +7,58 @@ defmodule ExplorerWeb.AddressChannel do |
|
|
|
|
alias ExplorerWeb.{AddressTransactionView, AddressView} |
|
|
|
|
alias Phoenix.View |
|
|
|
|
|
|
|
|
|
intercept(["balance_update", "transaction"]) |
|
|
|
|
intercept(["balance_update", "count", "transaction"]) |
|
|
|
|
|
|
|
|
|
def join("addresses:" <> _address_hash, _params, socket) do |
|
|
|
|
{:ok, %{}, socket} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def handle_out("transaction", %{address: address, transaction: transaction}, socket) do |
|
|
|
|
def handle_out( |
|
|
|
|
"balance_update", |
|
|
|
|
%{address: address, exchange_rate: exchange_rate}, |
|
|
|
|
socket |
|
|
|
|
) do |
|
|
|
|
Gettext.put_locale(ExplorerWeb.Gettext, socket.assigns.locale) |
|
|
|
|
|
|
|
|
|
rendered = |
|
|
|
|
View.render_to_string( |
|
|
|
|
AddressTransactionView, |
|
|
|
|
"_transaction.html", |
|
|
|
|
AddressView, |
|
|
|
|
"_balance_card.html", |
|
|
|
|
locale: socket.assigns.locale, |
|
|
|
|
address: address, |
|
|
|
|
transaction: transaction |
|
|
|
|
exchange_rate: exchange_rate |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
push(socket, "transaction", %{ |
|
|
|
|
to_address_hash: to_string(transaction.to_address_hash), |
|
|
|
|
from_address_hash: to_string(transaction.from_address_hash), |
|
|
|
|
transaction_html: rendered |
|
|
|
|
}) |
|
|
|
|
push(socket, "balance", %{balance: rendered}) |
|
|
|
|
{:noreply, socket} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def handle_out("count", %{count: count}, socket) do |
|
|
|
|
Gettext.put_locale(ExplorerWeb.Gettext, socket.assigns.locale) |
|
|
|
|
|
|
|
|
|
push(socket, "count", %{count: Cldr.Number.to_string!(count, format: "#,###")}) |
|
|
|
|
|
|
|
|
|
{:noreply, socket} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def handle_out( |
|
|
|
|
"balance_update", |
|
|
|
|
%{address: address, exchange_rate: exchange_rate}, |
|
|
|
|
socket |
|
|
|
|
) do |
|
|
|
|
def handle_out("transaction", %{address: address, transaction: transaction}, socket) do |
|
|
|
|
Gettext.put_locale(ExplorerWeb.Gettext, socket.assigns.locale) |
|
|
|
|
|
|
|
|
|
rendered = |
|
|
|
|
View.render_to_string( |
|
|
|
|
AddressView, |
|
|
|
|
"_balance_card.html", |
|
|
|
|
AddressTransactionView, |
|
|
|
|
"_transaction.html", |
|
|
|
|
locale: socket.assigns.locale, |
|
|
|
|
address: address, |
|
|
|
|
exchange_rate: exchange_rate |
|
|
|
|
transaction: transaction |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
push(socket, "balance", %{balance: rendered}) |
|
|
|
|
push(socket, "transaction", %{ |
|
|
|
|
to_address_hash: to_string(transaction.to_address_hash), |
|
|
|
|
from_address_hash: to_string(transaction.from_address_hash), |
|
|
|
|
transaction_html: rendered |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
{:noreply, socket} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|