diff --git a/src/Action.hs b/src/Action.hs index 4feac96..a58b79a 100644 --- a/src/Action.hs +++ b/src/Action.hs @@ -34,5 +34,5 @@ data Action | SearchAction Search.Action | GoToTime UTCTime | ChangeURI URI - | SearchResults [ CatalogPost ] + | SearchResults | NoAction diff --git a/src/Component/Search.hs b/src/Component/Search.hs index f75f9cb..8c08b3c 100644 --- a/src/Component/Search.hs +++ b/src/Component/Search.hs @@ -25,6 +25,7 @@ import Miso , (<#) , consoleLog , noEff + , batchEff ) import Data.JSString (pack) import qualified Network.Client as Client @@ -53,8 +54,11 @@ update iface (SearchResult result) model = model <# do consoleLog $ (pack $ show $ body) case body of - Just b -> return $ (searchResults iface) b - Nothing -> return $ (searchResults iface) [] + Just catlg_posts -> return $ passAction iface $ PassPostsToSelf catlg_posts + Nothing -> return $ passAction iface $ PassPostsToSelf [] + +update iface (PassPostsToSelf search_results) model = model { displayResults = search_results } <# + return (searchResults iface) update _ NoAction m = noEff m diff --git a/src/Component/Search/SearchTypes.hs b/src/Component/Search/SearchTypes.hs index 5ea6000..04b08dd 100644 --- a/src/Component/Search/SearchTypes.hs +++ b/src/Component/Search/SearchTypes.hs @@ -10,16 +10,17 @@ data Action = SearchChange JSString | OnSubmit | SearchResult (HttpResult [ CatalogPost ]) - | DisplayResults [ CatalogPost ] + | PassPostsToSelf [ CatalogPost ] -- I think I don't understand something about the update type but I had to add this... | NoAction data Model = Model { searchTerm :: JSString , clientModel :: Client.Model + , displayResults :: [ CatalogPost ] } deriving Eq data Interface a = Interface { passAction :: Action -> a , clientIface :: Client.Interface a [ CatalogPost ] - , searchResults :: [ CatalogPost ] -> a + , searchResults :: a } diff --git a/src/Main.hs b/src/Main.hs index e5f4757..f5e6f3c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -106,6 +106,7 @@ initialModel pgroot client_fetch_count media_root u t = Model , search_model = Search.Model { Search.searchTerm = "" , Search.clientModel = client_model_ + , Search.displayResults = [] } }