From 4c280a5bca9d87eaf4c7a5794c0045e3b70466b6 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Tue, 16 Aug 2022 15:51:39 -0700 Subject: [PATCH] Use helper function. --- examples/todos/app/Route/Visibility__.elm | 49 +++++------------------ 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/examples/todos/app/Route/Visibility__.elm b/examples/todos/app/Route/Visibility__.elm index 52ee4abc..03aaae01 100644 --- a/examples/todos/app/Route/Visibility__.elm +++ b/examples/todos/app/Route/Visibility__.elm @@ -188,46 +188,15 @@ action routeParams = ) Ok (Delete itemId) -> - okSessionThing - |> Session.get "sessionId" - |> Maybe.map Data.Session.get - |> Maybe.map Request.Hasura.dataSource - |> Maybe.map - (DataSource.andThen - (\maybeUserSession -> - let - bar : Maybe Uuid - bar = - maybeUserSession - |> Maybe.map .id - in - case bar of - Nothing -> - DataSource.succeed - ( okSessionThing - , Response.render {} - ) - - Just userId -> - Data.Todo.delete - { userId = userId - , itemId = Uuid itemId - } - |> Request.Hasura.mutationDataSource - |> DataSource.map - (\() -> - ( okSessionThing - , Response.render {} - ) - ) - ) - ) - |> Maybe.withDefault - (DataSource.succeed - ( okSessionThing - , Response.render {} - ) - ) + withUserSession session + (\userId -> + Data.Todo.delete + { userId = userId + , itemId = Uuid itemId + } + |> Request.Hasura.mutationDataSource + |> DataSource.map (\() -> Response.render {}) + ) Ok (Check ( newCompleteValue, itemId )) -> okSessionThing