defmodule SomethingErlangWeb.BookmarksLive do
use SomethingErlangWeb, :live_view
alias SomethingErlang.Grover
def render(assigns) do
~H"""
<.bookmark
:for={thread <- @bookmarks}
id={thread.id}
title={thread.title.thread_title}
post_count={thread.replies}
/>
"""
end
defp bookmark(assigns) do
assigns = assign(assigns, :pages, trunc(assigns.post_count / 40))
~H"""
<.link href={~p"/thread/#{@id}"}><%= @title %>
<.link href={~p"/thread/#{@id}?page=#{@pages}"}><%= @pages %>
"""
end
def mount(_params, session, socket) do
user =
socket.assigns.current_user
|> Map.put(:bbpassword, session["bbpassword"])
Grover.mount(user)
{:ok,
socket
|> assign(:page_title, "Bookmarks")
|> assign(:bookmarks, Grover.get_bookmarks!(1) |> dbg())}
end
end