grover without dynamicsupervisor?

This commit is contained in:
2024-08-13 09:48:50 +02:00
parent 256c883488
commit 24b0942a13
2 changed files with 24 additions and 44 deletions

View File

@ -4,10 +4,12 @@ defmodule SomethingErlangWeb.BookmarksLive do
alias SomethingErlang.Grover
def render(assigns) do
assigns.bookmarks |> dbg()
~H"""
<div :if={@bookmarks}>
<div :if={bookmarks = @bookmarks.ok? && @bookmarks.result}>
<.bookmark
:for={thread <- @bookmarks}
:for={thread <- bookmarks}
id={thread.id}
title={thread.title.thread_title}
post_count={thread.replies}
@ -32,11 +34,21 @@ defmodule SomethingErlangWeb.BookmarksLive do
socket.assigns.current_user
|> Map.put(:bbpassword, session["bbpassword"])
Grover.mount(user)
{:ok, pid} = Grover.start_link(user) |> dbg()
{:ok,
socket
|> assign(:page_title, "Bookmarks")
|> assign(:bookmarks, Grover.get_bookmarks!(1) |> dbg())}
|> assign_async(:bookmarks, fn ->
{:ok, bookmarks} = get_bookmarks(pid)
{:ok, %{bookmarks: bookmarks}}
end)}
end
defp get_bookmarks(pid) do
case Grover.get_bookmarks!(pid, 1) do
bookmarks when is_list(bookmarks) -> {:ok, bookmarks}
_ -> {:error, "Failed getting bookmarks"}
end
end
end