From 410ad0d4b40e2ae3ca315a9c808a886ab2c7bf2d Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:29:41 -0700 Subject: [PATCH] fix: failure to load SearchByNameModal (#3000) --- .../RequestModal/SearchByNameModal/index.tsx | 62 +++++++++++++++---- .../RequestModal/TvRequestModal.tsx | 4 +- src/i18n/locale/en.json | 4 +- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/components/RequestModal/SearchByNameModal/index.tsx b/src/components/RequestModal/SearchByNameModal/index.tsx index 5ba01534..0c42017e 100644 --- a/src/components/RequestModal/SearchByNameModal/index.tsx +++ b/src/components/RequestModal/SearchByNameModal/index.tsx @@ -1,5 +1,4 @@ import Alert from '@app/components/Common/Alert'; -import { SmallLoadingSpinner } from '@app/components/Common/LoadingSpinner'; import Modal from '@app/components/Common/Modal'; import globalMessages from '@app/i18n/globalMessages'; import type { SonarrSeries } from '@server/api/servarr/sonarr'; @@ -8,30 +7,30 @@ import useSWR from 'swr'; const messages = defineMessages({ notvdbiddescription: - "We couldn't automatically match your request. Please select the correct match from the list below.", - nosummary: 'No summary for this title was found.', + 'We were unable to automatically match this series. Please select the correct match below.', + nomatches: 'We were unable to find a match for this series.', }); interface SearchByNameModalProps { setTvdbId: (id: number) => void; tvdbId: number | undefined; - loading: boolean; onCancel?: () => void; closeModal: () => void; modalTitle: string; modalSubTitle: string; tmdbId: number; + backdrop?: string; } const SearchByNameModal = ({ setTvdbId, tvdbId, - loading, onCancel, closeModal, modalTitle, modalSubTitle, tmdbId, + backdrop, }: SearchByNameModalProps) => { const intl = useIntl(); const { data, error } = useSWR( @@ -42,9 +41,25 @@ const SearchByNameModal = ({ setTvdbId(tvdbId); }; + if ((data ?? []).length === 0 || error) { + return ( + + + + ); + } + return ( - {!data && !error && }
{data?.slice(0, 6).map((item) => ( diff --git a/src/components/RequestModal/TvRequestModal.tsx b/src/components/RequestModal/TvRequestModal.tsx index 0464d1b3..bd4ca37d 100644 --- a/src/components/RequestModal/TvRequestModal.tsx +++ b/src/components/RequestModal/TvRequestModal.tsx @@ -358,18 +358,18 @@ const TvRequestModal = ({ const isOwner = editRequest && editRequest.requestedBy.id === user?.id; - return data && !data.externalIds.tvdbId && searchModal.show ? ( + return data && !error && !data.externalIds.tvdbId && searchModal.show ? ( setSearchModal({ show: false })} - loading={!error} onCancel={onCancel} modalTitle={intl.formatMessage( is4k ? messages.requestseries4ktitle : messages.requestseriestitle )} modalSubTitle={data.name} tmdbId={tmdbId} + backdrop={`https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/${data?.backdropPath}`} /> ) : ( {seasons} {seasons, plural, one {season request} other {season requests}} remaining in order to submit a request for this series.", "components.RequestModal.QuotaDisplay.season": "season", "components.RequestModal.QuotaDisplay.seasonlimit": "{limit, plural, one {season} other {seasons}}", - "components.RequestModal.SearchByNameModal.nosummary": "No summary for this title was found.", - "components.RequestModal.SearchByNameModal.notvdbiddescription": "We couldn't automatically match your request. Please select the correct match from the list below.", + "components.RequestModal.SearchByNameModal.nomatches": "We were unable to find a match for this series.", + "components.RequestModal.SearchByNameModal.notvdbiddescription": "We were unable to automatically match this series. Please select the correct match below.", "components.RequestModal.alreadyrequested": "Already Requested", "components.RequestModal.approve": "Approve Request", "components.RequestModal.autoapproval": "Automatic Approval",