Skip to content

Commit

Permalink
Merge pull request #1087 from morucci/1082
Browse files Browse the repository at this point in the history
fix author search not working since last stable
  • Loading branch information
morucci authored Nov 24, 2023
2 parents df8653a + 984d24e commit b6f17ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
### Removed
### Fixed

- [web] authors search returning no results #1082

## [1.10.0] - 2023-11-06

### Added
Expand Down
9 changes: 6 additions & 3 deletions src/Monocle/Api/ServerHTMX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ searchAuthorsHandler :: ApiEffects es => AuthResult AuthenticatedUser -> Maybe C
searchAuthorsHandler _ Nothing _ = pure $ pure ()
searchAuthorsHandler auth (Just index) queryM = do
case queryM of
Just query -> do
Just authorName -> do
logInfo "Search request for author" ["author" .= authorName, "index" .= index]
(SearchPB.AuthorResponse results) <-
searchAuthor auth (AuthorRequest (from index) (from query))
searchAuthor auth (AuthorRequest (from index) (from authorName))
case toList results of
[] -> pure $ div_ "No Results"
_xs -> pure $ mapM_ authorToMarkup results
Expand All @@ -47,14 +48,16 @@ searchAuthorsHandler auth (Just index) queryM = do
, class_ "pf-c-form-control"
, placeholder_ "Start typing to search authors"
, hxGet "/htmx/authors_search"
, hxVals [iii|{"index": "#{index}"}|]
, hxVals [iii|{"index": "#{indexVal}"}|]
, hxTrigger "keyup changed delay:500ms, search"
, hxTarget "#search-results"
]
div_ [class_ "pf-l-stack__item"] $ do
div_ [id_ "search-results"] ""
script_ pushToRouter
where
indexVal :: Text
indexVal = from index
countCachedAuthors = do
resp <- esCountByIndex (tenantIndexName index) $ BH.CountQuery $ documentType ECachedAuthor
case resp of
Expand Down

0 comments on commit b6f17ff

Please sign in to comment.