Browse Source

chore: clean up

main
Inhji Y. 7 months ago
parent
commit
fbbbc48a46
  1. 2
      lib/mirage/lists.ex
  2. 4
      lib/mirage_web/live/blog_live.ex
  3. 7
      lib/mirage_web/live/list_live/show.ex
  4. 8
      lib/mirage_web/live/note_live/show.ex

2
lib/mirage/lists.ex

@ -42,6 +42,8 @@ defmodule Mirage.Lists do
def get_list_by_name(name), do: Repo.get_by(List, name: name) |> Repo.preload(@list_preloads)
def preload_list(list), do: Repo.preload(list, @list_preloads)
@doc """
Creates a list.

4
lib/mirage_web/live/blog_live.ex

@ -1,4 +1,8 @@
defmodule MirageWeb.BlogLive do
@moduledoc """
A page which shows all notes in the list @blog
"""
use MirageWeb, :live_view
@impl true

7
lib/mirage_web/live/list_live/show.ex

@ -1,6 +1,9 @@
defmodule MirageWeb.ListLive.Show do
use MirageWeb, :live_view
@moduledoc """
Shows lists and their edit form
"""
use MirageWeb, :live_view
alias Mirage.Lists
@impl true
@ -13,7 +16,7 @@ defmodule MirageWeb.ListLive.Show do
{:noreply,
socket
|> assign(:page_title, page_title(socket.assigns.live_action))
|> assign(:list, Lists.get_list!(id) |> IO.inspect())}
|> assign(:list, Lists.get_list!(id))}
end
defp page_title(:show), do: "Show List"

8
lib/mirage_web/live/note_live/show.ex

@ -1,4 +1,8 @@
defmodule MirageWeb.NoteLive.Show do
@moduledoc """
Shows notes and their edit form
"""
use MirageWeb, :live_view
alias Mirage.Notes
@ -39,7 +43,7 @@ defmodule MirageWeb.NoteLive.Show do
def handle_event("save_link", %{"link" => link}, socket) do
note_id = socket.assigns.note.id
with {:ok, link} <- Links.create_link(link),
with {:ok, link} <- Links.create_link_or_return_existing(link),
{:ok, _note_link} <- Notes.create_note_link(%{link_id: link.id, note_id: note_id}) do
note =
note_id
@ -53,7 +57,7 @@ defmodule MirageWeb.NoteLive.Show do
link_changeset: Link.changeset(%Link{}, %{note_id: note_id})
})}
else
_ ->
_error ->
{:noreply, socket}
end
end

Loading…
Cancel
Save