Skip to content

Commit

Permalink
Fix interface fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardarella committed May 2, 2024
1 parent 5f82496 commit 88b2baa
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/live_view_native/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ defmodule LiveViewNative.Utils do
@moduledoc false
alias Phoenix.LiveView.Socket

def get_format(%Socket{private: %{connect_info: %{private: %{phoenix_format: format}}}}), do: format
def get_format(%Socket{private: %{connect_params: %{"_format" => format}}}), do: format
def get_format(_socket), do: "html"
def get_format(%Socket{private: %{connect_info: %{private: %{phoenix_format: format}}}}),
do: format
def get_format(%Socket{private: %{connect_params: %{"_format" => format}}}),
do: format
def get_format(_socket),
do: "html"

def get_interface(%{socket: %Socket{private: %{connect_info: %{params: %{"_interface" => interface}}}}}), do: interface
def get_interface(%{conn: %Plug.Conn{params: %{"_interface" => interface}}}), do: interface
def get_interface(_socket), do: %{}
def get_interface(%{socket: %Socket{private: %{connect_params: %{"_interface" => interface}}}}),
do: interface
def get_interface(%{conn: %Plug.Conn{params: %{"_interface" => interface}}}),
do: interface
def get_interface(%{socket: %Socket{private: %{connect_info: %Plug.Conn{params: %{"_interface" => interface}}}}}),
do: interface
def get_interface(_assigns),
do: %{}

def stringify_format(format) when is_binary(format), do: format
def stringify_format(format) when is_atom(format), do: Atom.to_string(format)
Expand Down

0 comments on commit 88b2baa

Please sign in to comment.