Skip to content

Commit

Permalink
Discard effects when routing only query params
Browse files Browse the repository at this point in the history
resolves #225
  • Loading branch information
turboMaCk committed Nov 18, 2020
1 parent 7ac72dc commit 77bf383
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Main.elm
Expand Up @@ -160,7 +160,14 @@ changeRouteTo :
-> ( Model, Cmd Msg )
changeRouteTo currentModel url =
let
attempteQuery (( newModel, cmd ) as pair) =
attempteQuery ( newModel, cmd ) =
let
-- We intentially throw away Cmd
-- because we don't want to perform any effects
-- in this cases where route itself doesn't change
noEffects =
( newModel, Cmd.none )
in
case ( currentModel.route, newModel.route ) of
( Route.Packages arg1, Route.Packages arg2 ) ->
if
Expand All @@ -173,7 +180,7 @@ changeRouteTo currentModel url =
submitQuery newModel ( newModel, cmd )

else
pair
noEffects

( Route.Options arg1, Route.Options arg2 ) ->
if
Expand All @@ -186,14 +193,14 @@ changeRouteTo currentModel url =
submitQuery newModel ( newModel, cmd )

else
pair
noEffects

( a, b ) ->
if a /= b then
submitQuery newModel ( newModel, cmd )

else
pair
noEffects
in
case Route.fromUrl url of
Nothing ->
Expand Down

0 comments on commit 77bf383

Please sign in to comment.