BUG: clear liveview (#22)

Fixes #18
This commit is contained in:
Matthew Ryan Dillon 2020-06-22 21:00:47 -07:00 committed by GitHub
parent 58ceec6d79
commit c1b72074ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -10,6 +10,7 @@ defmodule PlannerWeb.LandingLive do
def mount(_params, _session, socket) do
socket =
socket
|> clear_flash(:info)
|> assign(:new_task_changeset, Tasks.change_task(%Task{}))
{:ok, socket}
@ -32,10 +33,12 @@ defmodule PlannerWeb.LandingLive do
def handle_event("save_new_task", %{"task" => task_params}, socket) do
case Tasks.add_task(task_params) do
{:ok, _task} ->
{:ok, task} ->
{:noreply,
socket
|> put_flash(:info, "task created")}
|> clear_flash(:info)
|> put_flash(:info, "task '" <> task.value <> "' created")
|> assign(:new_task_changeset, Tasks.change_task(%Task{}))}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply,