Skip to content

Commit

Permalink
Jisho: Pass user agent to comply with API changes. (#7466)
Browse files Browse the repository at this point in the history
Fixes  #7432

* fix user-agent bug #7432

* prettier

---------

Co-authored-by: Sorin Muntean <me@sorinmuntean.ro>
  • Loading branch information
dmacdermott and sxn authored Jul 11, 2023
1 parent 9fe9712 commit 0b52153
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
13 changes: 9 additions & 4 deletions extensions/jisho/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Jisho Changelog

## [Feature] - 2023-01-28
- Added Search History command.
## [Fix] - 2023-07-11

## [Fix] - 2022-07-04
- Fixed a bug where results were not fetched due to no User-Agent being set as a result of Jisho API changes.

- Fixed a bug where it was not possible to open the result in browserわたしは…です
## [Feature] - 2023-01-28

- Added Search History command.

## [Fix] - 2022-07-04

- Fixed a bug where it was not possible to open the result in browserわたしは…です
22 changes: 22 additions & 0 deletions extensions/jisho/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions extensions/jisho/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"prettier": "^3.0.0",
"react-devtools": "^4.19.2",
"typescript": "^4.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/jisho/src/components/SearchResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function SearchResultItem({
const title = searchResult.kanji || searchResult.reading;
const onChoose = useCallback(
() => addToHistory(SearchHistoryItems.resultItem(searchResult)),
[searchResult, addToHistory]
[searchResult, addToHistory],
);

return (
Expand Down
3 changes: 3 additions & 0 deletions extensions/jisho/src/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const useSearch = (initialSearchText: string) => {
const [searchText, setSearchText] = useState<string>(initialSearchText);

const { isLoading, data } = useFetch(`https://jisho.org/api/v1/search/words?keyword=${searchText}`, {
headers: {
"User-Agent": "Raycast Jisho Extension",
},
parseResponse: parseResponse,
initialData: [],
keepPreviousData: true,
Expand Down

0 comments on commit 0b52153

Please sign in to comment.