Use helper function.

This commit is contained in:
Dillon Kearns 2022-08-16 15:50:23 -07:00
parent c6986fc1fc
commit 8f60815d22

View File

@ -168,43 +168,12 @@ action routeParams =
)
Ok DeleteComplete ->
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.clearCompletedTodos userId
|> Request.Hasura.mutationDataSource
|> DataSource.map
(\() ->
( okSessionThing
, Response.render {}
)
)
)
)
|> Maybe.withDefault
(DataSource.succeed
( okSessionThing
, Response.render {}
)
)
withUserSession session
(\userId ->
Data.Todo.clearCompletedTodos userId
|> Request.Hasura.mutationDataSource
|> DataSource.map (\() -> Response.render {})
)
Ok (UpdateEntry ( itemId, newDescription )) ->
okSessionThing