grover
This commit is contained in:
@ -3,21 +3,49 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
|
||||
on_mount SomethingErlangWeb.UserLiveAuth
|
||||
|
||||
alias SomethingErlang.Forums
|
||||
alias SomethingErlang.Grover
|
||||
|
||||
require Logger
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
socket |> IO.inspect
|
||||
def mount(%{"id" => id} = _params, _session, socket) do
|
||||
Grover.mount(self(), socket.assigns.current_user, id)
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
def handle_params(%{"id" => id, "page" => page}, _, socket) do
|
||||
thread = Grover.get_thread!(self(), id, page |> String.to_integer())
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action))
|
||||
|> assign(:thread, Forums.get_thread!(id))}
|
||||
|> assign(:thread, thread)}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: "Show Thread"
|
||||
defp page_title(:edit), do: "Edit Thread"
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
{:noreply, push_redirect(socket,
|
||||
to: Routes.thread_show_path(socket, :show, id, page: 1))}
|
||||
end
|
||||
|
||||
def post(assigns) do
|
||||
~H"""
|
||||
<div class="post">
|
||||
<.user info={@author} />
|
||||
<article class="grow-1 w-full">
|
||||
<%= raw @article %>
|
||||
</article>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def user(assigns) do
|
||||
~H"""
|
||||
<aside class="userinfo shrink-0 w-[13em]">
|
||||
<h3><%= @info.name %></h3>
|
||||
<div class="title">
|
||||
<%= raw @info.title %>
|
||||
</div>
|
||||
</aside>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user