From 23d9fd0b40f1eef919f35a6f84ffb5befc51add2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 21 Oct 2020 15:45:30 -0400 Subject: [PATCH] Use GraphQL search endpoints, see #33 --- frontEndSrc/js/anime.js | 2 +- frontEndSrc/js/manga.js | 2 +- frontEndSrc/js/template-helpers.js | 26 +++++----- public/es/scripts.js | 30 ++++++----- public/js/scripts.min.js | 25 +++++----- public/js/scripts.min.js.map | 2 +- src/AnimeClient/API/Kitsu/Model.php | 50 +++++++++---------- .../API/Kitsu/Queries/SearchAnime.graphql | 19 +++++++ .../API/Kitsu/Queries/SearchManga.graphql | 19 +++++++ src/AnimeClient/API/Kitsu/RequestBuilder.php | 2 + 10 files changed, 106 insertions(+), 71 deletions(-) create mode 100644 src/AnimeClient/API/Kitsu/Queries/SearchAnime.graphql create mode 100644 src/AnimeClient/API/Kitsu/Queries/SearchManga.graphql diff --git a/frontEndSrc/js/anime.js b/frontEndSrc/js/anime.js index 3d92af9e..c0a7fad3 100644 --- a/frontEndSrc/js/anime.js +++ b/frontEndSrc/js/anime.js @@ -13,7 +13,7 @@ const search = (query) => { _.hide('.cssload-loader'); // Show the results - _.$('#series-list')[ 0 ].innerHTML = renderAnimeSearchResults(searchResults.data); + _.$('#series-list')[ 0 ].innerHTML = renderAnimeSearchResults(searchResults); }); }; diff --git a/frontEndSrc/js/manga.js b/frontEndSrc/js/manga.js index f46460fe..cb8ad8a7 100644 --- a/frontEndSrc/js/manga.js +++ b/frontEndSrc/js/manga.js @@ -6,7 +6,7 @@ const search = (query) => { return _.get(_.url('/manga/search'), { query }, (searchResults, status) => { searchResults = JSON.parse(searchResults); _.hide('.cssload-loader'); - _.$('#series-list')[ 0 ].innerHTML = renderMangaSearchResults(searchResults.data); + _.$('#series-list')[ 0 ].innerHTML = renderMangaSearchResults(searchResults); }); }; diff --git a/frontEndSrc/js/template-helpers.js b/frontEndSrc/js/template-helpers.js index caf054b3..14ee6650 100644 --- a/frontEndSrc/js/template-helpers.js +++ b/frontEndSrc/js/template-helpers.js @@ -10,20 +10,19 @@ _.on('main', 'change', '.big-check', (e) => { export function renderAnimeSearchResults (data) { const results = []; - data.forEach(x => { - const item = x.attributes; + data.forEach(item => { const titles = item.titles.join('
'); results.push(`