|  |  |  | @ -3,9 +3,12 @@ defmodule ChirpWeb.PostLive.PostComponent do | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @spec render(any) :: Phoenix.LiveView.Rendered.t() | 
			
		
	
		
			
				
					|  |  |  |  |     def render(assigns) do | 
			
		
	
		
			
				
					|  |  |  |  |       #IO.inspect(assigns.post.__meta__.state) | 
			
		
	
		
			
				
					|  |  |  |  |       ~H""" | 
			
		
	
		
			
				
					|  |  |  |  |       <div id={"post #{assigns.post.id}"} class="container mx-auto"> | 
			
		
	
		
			
				
					|  |  |  |  |       <div  class="flex flex-row"> | 
			
		
	
		
			
				
					|  |  |  |  |       <div id={"post-#{assigns.post.id}"} class="container mx-auto" | 
			
		
	
		
			
				
					|  |  |  |  |       style={if @post.__meta__.state == :deleted, do: "display:none;", else: ""} | 
			
		
	
		
			
				
					|  |  |  |  |       > | 
			
		
	
		
			
				
					|  |  |  |  |       <div id={"postrow-for-#{assigns.post.id}"}  class="flex flex-row"> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         <div class="basis-1/4"> | 
			
		
	
		
			
				
					|  |  |  |  |           <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> | 
			
		
	
	
		
			
				
					|  |  |  | @ -14,11 +17,11 @@ defmodule ChirpWeb.PostLive.PostComponent do | 
			
		
	
		
			
				
					|  |  |  |  |           <div label="Username"><%= @post.username %></div> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         </div> | 
			
		
	
		
			
				
					|  |  |  |  |         <div class="basis-3/4"> | 
			
		
	
		
			
				
					|  |  |  |  |         <div id={"post-maincolumn-#{assigns.post.id}"} class="basis-3/4"> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         <div class="p-6 max-w-lg bg-white rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700"> | 
			
		
	
		
			
				
					|  |  |  |  |         <pre label="Body" class="mb-3 font-normal text-gray-500 dark:text-gray-400"><%= @post.body %></pre> | 
			
		
	
		
			
				
					|  |  |  |  |         <div class="grid grid-flow-col gap-4 auto-cols-max"> | 
			
		
	
		
			
				
					|  |  |  |  |         <div id={"post-cardbox-#{assigns.post.id}"} class="p-6 max-w-lg bg-white rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700"> | 
			
		
	
		
			
				
					|  |  |  |  |         <pre id={"body-#{assigns.post.id}"} label="Body" class="mb-3 font-normal text-gray-500 dark:text-gray-400"><%= @post.body %></pre> | 
			
		
	
		
			
				
					|  |  |  |  |         <div id={"buttons-#{assigns.post.id}"} class="grid grid-flow-col gap-4 auto-cols-max"> | 
			
		
	
		
			
				
					|  |  |  |  |           <div class="p-1"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link navigate={~p"/posts/#{@post}"} class="inline-flex items-center text-blue-600 hover:underline"> | 
			
		
	
		
			
				
					|  |  |  |  |             Show | 
			
		
	
	
		
			
				
					|  |  |  | @ -29,19 +32,19 @@ defmodule ChirpWeb.PostLive.PostComponent do | 
			
		
	
		
			
				
					|  |  |  |  |             </.link> | 
			
		
	
		
			
				
					|  |  |  |  |           </div> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |           <div class="p-1 flex flex-row"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click="like" phx-value-id={@post.id}> | 
			
		
	
		
			
				
					|  |  |  |  |           <div id={"likes-col-#{assigns.post.id}"} class="p-1 flex flex-row"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click="like" phx-value-id={@post.id} phx-target={@myself}> | 
			
		
	
		
			
				
					|  |  |  |  |             <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> | 
			
		
	
		
			
				
					|  |  |  |  |               <path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" /> | 
			
		
	
		
			
				
					|  |  |  |  |             </svg> | 
			
		
	
		
			
				
					|  |  |  |  |             </.link> | 
			
		
	
		
			
				
					|  |  |  |  |             <span label="Likes count"> | 
			
		
	
		
			
				
					|  |  |  |  |             <span id={"likes-count-#{assigns.post.id}"} label="Likes count"> | 
			
		
	
		
			
				
					|  |  |  |  |               <%= @post.likes_count %> | 
			
		
	
		
			
				
					|  |  |  |  |             </span> | 
			
		
	
		
			
				
					|  |  |  |  |           </div> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |           <div  class="p-1 flex flex-row"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click="repost" phx-value-id={@post.id}> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click="repost" phx-value-id={@post.id} phx-target={@myself}> | 
			
		
	
		
			
				
					|  |  |  |  |             <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> | 
			
		
	
		
			
				
					|  |  |  |  |               <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 00-3.7-3.7 48.678 48.678 0 00-7.324 0 4.006 4.006 0 00-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3l-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 003.7 3.7 48.656 48.656 0 007.324 0 4.006 4.006 0 003.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3l-3 3" /> | 
			
		
	
		
			
				
					|  |  |  |  |             </svg> | 
			
		
	
	
		
			
				
					|  |  |  | @ -54,10 +57,13 @@ defmodule ChirpWeb.PostLive.PostComponent do | 
			
		
	
		
			
				
					|  |  |  |  |             <.link patch={~p"/posts/#{@post}/edit"}>Edit</.link> | 
			
		
	
		
			
				
					|  |  |  |  |           </div> | 
			
		
	
		
			
				
					|  |  |  |  |           <div class="p-1"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click={JS.push("delete", value: %{id: @post.id})} data-confirm="Are you sure?"> | 
			
		
	
		
			
				
					|  |  |  |  |             <.link phx-click={JS.push("delete", value: %{id: @post.id})} phx-target={@myself} data-confirm="Are you sure?"> | 
			
		
	
		
			
				
					|  |  |  |  |               Delete | 
			
		
	
		
			
				
					|  |  |  |  |             </.link> | 
			
		
	
		
			
				
					|  |  |  |  |           </div> | 
			
		
	
		
			
				
					|  |  |  |  |           <div class="p-1"> | 
			
		
	
		
			
				
					|  |  |  |  |           <!-- 🗑: <%= if @post.__meta__.state == :deleted, do: "Yes", else: "No" %> --> | 
			
		
	
		
			
				
					|  |  |  |  |           </div> | 
			
		
	
		
			
				
					|  |  |  |  |         </div> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -75,4 +81,20 @@ defmodule ChirpWeb.PostLive.PostComponent do | 
			
		
	
		
			
				
					|  |  |  |  |       """ | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     def handle_event("like", _, socket) do | 
			
		
	
		
			
				
					|  |  |  |  |       Chirp.Timeline.inc_likes(socket.assigns.post) | 
			
		
	
		
			
				
					|  |  |  |  |       {:noreply,socket} | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  |     def handle_event("repost", _, socket) do | 
			
		
	
		
			
				
					|  |  |  |  |       Chirp.Timeline.inc_reposts(socket.assigns.post) | 
			
		
	
		
			
				
					|  |  |  |  |       {:noreply,socket} | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  |     def handle_event("delete", %{"id" => id}, socket) do | 
			
		
	
		
			
				
					|  |  |  |  |       post = Chirp.Timeline.get_post!(id) | 
			
		
	
		
			
				
					|  |  |  |  |       {:ok, _} = Chirp.Timeline.delete_post(post) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |       {:noreply, socket} | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | end | 
			
		
	
	
		
			
				
					|  |  |  | 
 |