memEx/lib/memex_web/live/note_live/show.ex

26 lines
562 B
Elixir
Raw Normal View History

2022-07-25 20:08:40 -04:00
defmodule MemexWeb.NoteLive.Show do
use MemexWeb, :live_view
alias Memex.Notes
@impl true
def mount(_params, _session, socket) do
{:ok, socket}
end
@impl true
2022-11-17 22:38:52 -05:00
def handle_params(
%{"id" => id},
_,
%{assigns: %{live_action: live_action, current_user: current_user}} = socket
) do
2022-07-25 20:08:40 -04:00
{:noreply,
socket
2022-11-17 22:38:52 -05:00
|> assign(:page_title, page_title(live_action))
|> assign(:note, Notes.get_note!(id, current_user))}
2022-07-25 20:08:40 -04:00
end
2022-11-17 22:30:01 -05:00
defp page_title(:show), do: "show note"
defp page_title(:edit), do: "edit note"
2022-07-25 20:08:40 -04:00
end