From 29f5f02a16c725f6e782bc1b0fde832efe1b8cdf Mon Sep 17 00:00:00 2001 From: Marek Fajkus Date: Thu, 19 Nov 2020 00:49:15 +0100 Subject: [PATCH] Discard effects when routing only query params (#229) fixes #225 --- src/Main.elm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index 6b027e6..b7d9152 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -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 @@ -173,7 +180,7 @@ changeRouteTo currentModel url = submitQuery newModel ( newModel, cmd ) else - pair + noEffects ( Route.Options arg1, Route.Options arg2 ) -> if @@ -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 ->