Skip to content

Commit

Permalink
Refactor presenter module to use endpoint configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alxlion committed Apr 18, 2024
1 parent f05b72b commit 16941ac
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/claper_web/live/event_live/presenter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@ defmodule ClaperWeb.EventLive.Presenter do
)
end

host =
case get_connect_params(socket) do
nil -> ""
%{"host" => host} -> host
end
endpoint_config = Application.get_env(:claper, ClaperWeb.Endpoint)[:url]
port = endpoint_config[:port]
scheme = endpoint_config[:scheme]
host = endpoint_config[:host]
path = endpoint_config[:path]

default_ports = [80, 443]
port_suffix = if port in default_ports, do: "", else: ":" <> Integer.to_string(port)

host = "#{scheme}://#{host}#{port_suffix}/#{path}"

socket =
socket
|> assign(:attendees_nb, 1)
|> assign(:host, host)
|> assign(
:host,
host
)
|> assign(:event, event)
|> assign(:state, event.presentation_file.presentation_state)
|> assign(:posts, list_posts(socket, event.uuid))
Expand Down

0 comments on commit 16941ac

Please sign in to comment.