update things

This commit is contained in:
zack 2024-10-26 22:38:41 -04:00
parent 984a193c5d
commit b2f2f57029
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
6 changed files with 27 additions and 9 deletions

View file

@ -6,7 +6,13 @@ defmodule ZoeyscomputerWeb.GistLive.Index do
@impl true
def mount(_params, _session, socket) do
{:ok, stream(socket, :gists, Gists.list_gists())}
socket = socket |> assign(:current_user, socket.assigns.current_user)
if connected?(socket) && socket.assigns.current_user do
{:ok, stream(socket, :gists, Gists.list_gists())}
else
{:ok, stream(socket, :gists, [])}
end
end
@impl true
@ -18,12 +24,14 @@ defmodule ZoeyscomputerWeb.GistLive.Index do
defp apply_action(socket, :edit, %{"id" => id}) do
socket
|> assign(:page_title, "Edit Gist")
|> assign(:current_user, socket.assigns.current_user)
|> assign(:gist, Gists.get_gist!(id))
end
defp apply_action(socket, :new, _params) do
socket
|> assign(:page_title, "New Gist")
|> assign(:current_user, socket.assigns.current_user)
|> assign(:gist, %Gist{
code: "",
lang: nil