From a7ac1d8e8c16b00ec4a3afe4421fa5d64a157d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Fri, 27 Jan 2023 18:49:55 +0100 Subject: [PATCH] frontend: reset `from` and `buckets` when changing pages (#595) Co-authored-by: Rok Garbas --- frontend/src/Main.elm | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm index 89a2b24..f8f2e74 100644 --- a/frontend/src/Main.elm +++ b/frontend/src/Main.elm @@ -413,27 +413,28 @@ view model = viewNavigation : Route.Route -> List (Html Msg) viewNavigation route = let - toRoute f = - case route of - -- Preserve arguments - Route.Packages searchArgs -> - f searchArgs + -- Preserve most arguments + searchArgs = + (\args -> { args | from = Nothing, buckets = Nothing }) <| + case route of + Route.Packages args -> + args - Route.Options searchArgs -> - f searchArgs + Route.Options args -> + args - Route.Flakes searchArgs -> - f searchArgs + Route.Flakes args -> + args - _ -> - f <| Route.SearchArgs Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing + _ -> + Route.SearchArgs Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing in li [] [ a [ href "https://nixos.org" ] [ text "Back to nixos.org" ] ] :: List.map (viewNavigationItem route) - [ ( toRoute Route.Packages, text "Packages" ) - , ( toRoute Route.Options, text "Options" ) - , ( toRoute Route.Flakes, span [] [ text "Flakes", sup [] [ span [ class "label label-info" ] [ small [] [ text "Experimental" ] ] ] ] ) + [ ( Route.Packages searchArgs, text "Packages" ) + , ( Route.Options searchArgs, text "Options" ) + , ( Route.Flakes searchArgs, span [] [ text "Flakes", sup [] [ span [ class "label label-info" ] [ small [] [ text "Experimental" ] ] ] ] ) ]