From 99eae108c7326511fde1c84f9947ba0b79eb2fb8 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Fri, 8 May 2020 23:59:14 +0200 Subject: [PATCH] search on page load and on second search query, fixes #5 (#8) --- src/Main.elm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index 55652a4..2ce0992 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -110,10 +110,7 @@ submitQuery : submitQuery old ( new, cmd ) = let triggerSearch oldModel newModel msg makeRequest = - if (oldModel.query == newModel.query) && RemoteData.isSuccess oldModel.result then - ( new, cmd ) - - else + if newModel.query /= Nothing then ( new , Cmd.batch [ cmd @@ -123,14 +120,23 @@ submitQuery old ( new, cmd ) = |> Cmd.map msg ] ) + + else + ( new, cmd ) in case ( old.page, new.page ) of ( Packages oldModel, Packages newModel ) -> triggerSearch oldModel newModel PackagesMsg Page.Packages.makeRequest + ( NotFound, Packages newModel ) -> + triggerSearch newModel newModel PackagesMsg Page.Packages.makeRequest + ( Options oldModel, Options newModel ) -> triggerSearch oldModel newModel OptionsMsg Page.Options.makeRequest + ( NotFound, Options newModel ) -> + triggerSearch newModel newModel OptionsMsg Page.Options.makeRequest + ( _, _ ) -> ( new, cmd )