Organize and refactor a bit

This commit is contained in:
Aaron Bieber 2023-05-22 07:08:13 -06:00
parent 5104c0d016
commit 6d098f6a25
No known key found for this signature in database

View File

@ -31,20 +31,20 @@ main =
type Msg type Msg
= Reload = AddedLink (Result Http.Error ())
| DeletedLink (Result Http.Error ())
| DeleteLink Int
| GotLinks (Result Http.Error (List Data.Link))
| GotNewLink NewLink
| GotNewWatch NewWatch
| GotWatches (Result Http.Error (List Data.Watch))
| HideWatchedItem Int String
| HidItem (Result Http.Error ())
| Reload
| ReloadLinks | ReloadLinks
| ReloadWatches | ReloadWatches
| GotWatches (Result Http.Error (List Data.Watch))
| GotLinks (Result Http.Error (List Data.Link))
| AddedLink (Result Http.Error ())
| DeletedLink (Result Http.Error ())
| HidItem (Result Http.Error ())
| SubmitLink | SubmitLink
| GotNewLink NewLink
| SubmitWatch | SubmitWatch
| GotNewWatch NewWatch
| HideWatchedItem Int String
| DeleteLink Int
type Status type Status
@ -202,7 +202,6 @@ update msg model =
( model, hideWatched itemId repo ) ( model, hideWatched itemId repo )
SubmitWatch -> SubmitWatch ->
-- TODO
( model, addWatch model ) ( model, addWatch model )
SubmitLink -> SubmitLink ->
@ -228,13 +227,7 @@ update msg model =
_ :: _ -> _ :: _ ->
( { model ( { model
| watches = watches | watches = watches
, status = , status = LoadedWatches watches
case List.head watches of
Just _ ->
LoadedWatches watches
Nothing ->
LoadedWatches []
} }
, Cmd.none , Cmd.none
) )
@ -248,18 +241,13 @@ update msg model =
( { model ( { model
| links = links | links = links
, status = , status =
case List.head links of
Just _ ->
LoadedLinks links LoadedLinks links
Nothing ->
LoadedLinks []
} }
, Cmd.none , Cmd.none
) )
[] -> [] ->
( { model | status = Errored "No Watches found" }, Cmd.none ) ( { model | status = Errored "No Links found" }, Cmd.none )
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg