update things
This commit is contained in:
parent
984a193c5d
commit
b2f2f57029
6 changed files with 27 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue