Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 77bf383

Browse files
committedNov 18, 2020
Discard effects when routing only query params
resolves #225
1 parent 7ac72dc commit 77bf383

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎src/Main.elm

+11-4
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ changeRouteTo :
160160
-> ( Model, Cmd Msg )
161161
changeRouteTo currentModel url =
162162
let
163-
attempteQuery (( newModel, cmd ) as pair) =
163+
attempteQuery ( newModel, cmd ) =
164+
let
165+
-- We intentially throw away Cmd
166+
-- because we don't want to perform any effects
167+
-- in this cases where route itself doesn't change
168+
noEffects =
169+
( newModel, Cmd.none )
170+
in
164171
case ( currentModel.route, newModel.route ) of
165172
( Route.Packages arg1, Route.Packages arg2 ) ->
166173
if
@@ -173,7 +180,7 @@ changeRouteTo currentModel url =
173180
submitQuery newModel ( newModel, cmd )
174181

175182
else
176-
pair
183+
noEffects
177184

178185
( Route.Options arg1, Route.Options arg2 ) ->
179186
if
@@ -186,14 +193,14 @@ changeRouteTo currentModel url =
186193
submitQuery newModel ( newModel, cmd )
187194

188195
else
189-
pair
196+
noEffects
190197

191198
( a, b ) ->
192199
if a /= b then
193200
submitQuery newModel ( newModel, cmd )
194201

195202
else
196-
pair
203+
noEffects
197204
in
198205
case Route.fromUrl url of
199206
Nothing ->

0 commit comments

Comments
 (0)
Please sign in to comment.