Skip to content

Commit

Permalink
Show Results Grid Even When Search Returned Only Error Lines (#58)
Browse files Browse the repository at this point in the history
* WIP.

* Allow manual downloads even if no results were parsable.
  • Loading branch information
evan-buss authored Jan 27, 2022
1 parent 10b9f20 commit c0e4548
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/search_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func parseLine(line string) (BookDetail, error) {
}

func ParseSearchV2(reader io.Reader) ([]BookDetail, []ParseError) {
var books []BookDetail
var parseErrors []ParseError
books := make([]BookDetail, 0)
parseErrors := make([]ParseError, 0)

scanner := bufio.NewScanner(reader)
for scanner.Scan() {
Expand Down
6 changes: 5 additions & 1 deletion server/app/src/components/ErrorsGrid/ErrorsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export default function ErrorsGrid({ errors }: Props) {
)
.map((book, i) => (
<Table.Row key={book.line + i} isSelectable>
<Table.TextCell flexBasis={250} flexGrow={1} flexShrink={0}>
<Table.TextCell
flexBasis={250}
flexGrow={1}
flexShrink={0}
cursor="text">
<code>{book.line}</code>
</Table.TextCell>
<Table.TextCell flexBasis={350} flexGrow={0} flexShrink={0}>
Expand Down
2 changes: 1 addition & 1 deletion server/app/src/components/SideBar/SearchHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const HistoryCard: React.FC<Props> = ({ activeTS, item, dispatch }: Props) => {
textOverflow="ellipsis">
{item.query}
</Text>
{!item.results?.length ? (
{!item.results?.length && !item.errors?.length ? (
<Spinner size={20} marginRight={5} />
) : (
<Badge color="blue">{`${item.results?.length} RESULTS`}</Badge>
Expand Down
2 changes: 1 addition & 1 deletion server/irc_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *Client) searchResultHandler(downloadDir string) core.HandlerFunc {
}
}

if len(results) == 0 {
if len(results) == 0 && len(errors) == 0 {
c.noResultsHandler(text)
return
}
Expand Down
8 changes: 7 additions & 1 deletion todo
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ Future:
after websocket disconnect.
- Convert grid to use React Grid instead of Evergreen's built in one.
- Things like styling are more difficult with Evergreen (ex. can't round the bottom corners)
- Send download progress updates to the browser like we show for the CLI
- Send download progress updates to the browser like we show for the CLI
- Improve message formats.
- Don't need as many separate message types. Just have functions that create them with the appropriate status code.
- Log the address to access it in the browser on startup
- When the results contain only lines that couldn't be parsed,
the grid doesn't show and user can't manually download.
- Prevent double clicking the download button.

0 comments on commit c0e4548

Please sign in to comment.