Hook in search into the update loop
- new SearchType module to prevent cyclical imports - Can't currently decode search results with the CatalogPost type, need to update the database search function
This commit is contained in:
parent
cd72af095e
commit
b42510f72c
|
@ -86,6 +86,7 @@ executable chandlr
|
|||
Parsing.PostPartType
|
||||
Component.TimeControl
|
||||
Component.Search
|
||||
Component.Search.SearchTypes
|
||||
|
||||
|
||||
-- LANGUAGE extensions used by modules in this package.
|
||||
|
|
|
@ -15,7 +15,7 @@ import Network.Http (HttpResult)
|
|||
import Network.SiteType (Site)
|
||||
import qualified Component.ThreadView as Thread
|
||||
import qualified Component.TimeControl as TC
|
||||
import qualified Component.Search as Search
|
||||
import qualified Component.Search.SearchTypes as Search
|
||||
|
||||
data GetThreadArgs = GetThreadArgs
|
||||
{ website :: Text
|
||||
|
|
|
@ -26,27 +26,10 @@ import Miso
|
|||
, consoleLog
|
||||
, noEff
|
||||
)
|
||||
import Data.JSString (JSString, pack)
|
||||
import qualified Network.ClientTypes as Client
|
||||
import Network.CatalogPostType (CatalogPost)
|
||||
import Data.JSString (pack)
|
||||
import qualified Network.Client as Client
|
||||
import Network.Http (HttpResult (..))
|
||||
|
||||
data Action
|
||||
= SearchChange JSString
|
||||
| OnSubmit
|
||||
| SearchResult (HttpResult [ CatalogPost ])
|
||||
| NoAction
|
||||
|
||||
data Model = Model
|
||||
{ searchTerm :: JSString
|
||||
, clientModel :: Client.Model
|
||||
} deriving Eq
|
||||
|
||||
data Interface a = Interface
|
||||
{ passAction :: Action -> a
|
||||
, clientIface :: Client.Interface a [ CatalogPost ]
|
||||
}
|
||||
|
||||
import Component.Search.SearchTypes
|
||||
|
||||
update :: Interface a -> Action -> Model -> Effect a Model
|
||||
update iface (SearchChange q) model = model { searchTerm = q } <# do
|
||||
|
@ -54,8 +37,8 @@ update iface (SearchChange q) model = model { searchTerm = q } <# do
|
|||
return $ (passAction iface) NoAction
|
||||
|
||||
update iface OnSubmit model = model <# do
|
||||
consoleLog $ "Submit!" <> searchTerm model
|
||||
return $ (passAction iface) NoAction
|
||||
consoleLog $ "Submit! " <> searchTerm model
|
||||
Client.search (clientModel model) (searchTerm model) (clientIface iface)
|
||||
|
||||
update iface (SearchResult result) model = model <# do
|
||||
consoleLog $ "Search result"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
module Component.Search.SearchTypes where
|
||||
|
||||
import Data.JSString (JSString)
|
||||
import Network.Http (HttpResult (..))
|
||||
|
||||
import qualified Network.ClientTypes as Client
|
||||
import Network.CatalogPostType (CatalogPost)
|
||||
|
||||
data Action
|
||||
= SearchChange JSString
|
||||
| OnSubmit
|
||||
| SearchResult (HttpResult [ CatalogPost ])
|
||||
| NoAction
|
||||
|
||||
data Model = Model
|
||||
{ searchTerm :: JSString
|
||||
, clientModel :: Client.Model
|
||||
} deriving Eq
|
||||
|
||||
data Interface a = Interface
|
||||
{ passAction :: Action -> a
|
||||
, clientIface :: Client.Interface a [ CatalogPost ]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue