Simplify code and remove infinite redirect

This commit is contained in:
stuart nelson 2016-11-23 09:45:24 +01:00
parent 8a82068b2b
commit e1e64f4415
2 changed files with 5 additions and 18 deletions

View File

@ -29,7 +29,7 @@ init location =
route =
Parsing.urlParser location
in
( Model [] (Silence 0 "" "" "" "" "" []) [] (Alert "") route, routeCmd route )
update (urlUpdate location) (Model [] (Silence 0 "" "" "" "" "" []) [] (Alert "") route)
update : Msg -> Model -> ( Model, Cmd Msg )
@ -54,21 +54,8 @@ update msg model =
FetchSilence id ->
( { model | route = SilenceRoute id }, Api.getSilence id )
RedirectAlerts ->
( { model | route = AlertsRoute }, Navigation.newUrl "/#/alerts" )
routeCmd : Route -> Cmd Msg
routeCmd route =
case route of
SilencesRoute ->
Api.getSilences
SilenceRoute id ->
Api.getSilence id
_ ->
Cmd.none
RedirectSilences ->
( { model | route = AlertsRoute }, Navigation.newUrl "/#/silences" )
urlUpdate : Navigation.Location -> Msg
@ -86,7 +73,7 @@ urlUpdate location =
_ ->
-- TODO: 404 page
RedirectAlerts
RedirectSilences

View File

@ -53,7 +53,7 @@ type Msg
| SilencesFetch (Result Http.Error (List Silence))
| FetchSilences
| FetchSilence String
| RedirectAlerts
| RedirectSilences
type Route