From fc507244cdf3acb0ca67d2d1013bbfaf3e174369 Mon Sep 17 00:00:00 2001
From: Anatole Sot <47571181+ano0002@users.noreply.github.com>
Date: Sat, 24 Feb 2024 21:13:13 +0100
Subject: [PATCH] Fixed a bug that caused some artist to crash the discover
page if recently added and fixed the lidarr setting pop up not displaying the
current lidarr installation
---
server/api/musicbrainz/poster.ts | 14 +++++++------
src/components/Common/CachedImage/index.tsx | 12 ++++++++---
src/components/Settings/SettingsServices.tsx | 21 +++++++++++++-------
3 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/server/api/musicbrainz/poster.ts b/server/api/musicbrainz/poster.ts
index 0a8aa134..a13f2f97 100644
--- a/server/api/musicbrainz/poster.ts
+++ b/server/api/musicbrainz/poster.ts
@@ -17,12 +17,14 @@ function getPosterFromMB(
});
try {
const artist = (lidarr as LidarrAPI).getArtist(element.id);
- return LidarrAPI.buildUrl(
- lidarrSettings,
- (artist.images ?? [{ coverType: 'poster', url: undefined }]).find(
- (i) => i.coverType === 'poster'
- )?.url
- );
+ if (artist.images.find((i) => i.coverType === 'poster')?.url) {
+ return LidarrAPI.buildUrl(
+ lidarrSettings,
+ artist.images.find((i) => i.coverType === 'poster')?.url
+ );
+ } else {
+ return undefined;
+ }
} catch (e) {
return undefined;
}
diff --git a/src/components/Common/CachedImage/index.tsx b/src/components/Common/CachedImage/index.tsx
index 95b56bad..8f88fcd1 100644
--- a/src/components/Common/CachedImage/index.tsx
+++ b/src/components/Common/CachedImage/index.tsx
@@ -17,7 +17,6 @@ const CachedImage = ({ src, ...props }: ImageProps) => {
setImageUrl(currentSettings?.fallbackImage);
};
-
if (typeof imageUrl === 'string' && imageUrl.startsWith('http')) {
const parsedUrl = new URL(imageUrl);
@@ -26,8 +25,15 @@ const CachedImage = ({ src, ...props }: ImageProps) => {
}
}
-
- return ;
+ return (
+
+ );
};
export default CachedImage;
diff --git a/src/components/Settings/SettingsServices.tsx b/src/components/Settings/SettingsServices.tsx
index 331b0aff..f9fa305a 100644
--- a/src/components/Settings/SettingsServices.tsx
+++ b/src/components/Settings/SettingsServices.tsx
@@ -1,19 +1,23 @@
+import LidarrLogo from '@app/assets/services/lidarr.svg';
import RadarrLogo from '@app/assets/services/radarr.svg';
import SonarrLogo from '@app/assets/services/sonarr.svg';
-import LidarrLogo from '@app/assets/services/lidarr.svg';
import Alert from '@app/components/Common/Alert';
import Badge from '@app/components/Common/Badge';
import Button from '@app/components/Common/Button';
import LoadingSpinner from '@app/components/Common/LoadingSpinner';
import Modal from '@app/components/Common/Modal';
import PageTitle from '@app/components/Common/PageTitle';
+import LidarrModal from '@app/components/Settings/LidarrModal';
import RadarrModal from '@app/components/Settings/RadarrModal';
import SonarrModal from '@app/components/Settings/SonarrModal';
-import LidarrModal from '@app/components/Settings/LidarrModal';
import globalMessages from '@app/i18n/globalMessages';
import { Transition } from '@headlessui/react';
import { PencilIcon, PlusIcon, TrashIcon } from '@heroicons/react/24/solid';
-import type { RadarrSettings, SonarrSettings, LidarrSettings } from '@server/lib/settings';
+import type {
+ LidarrSettings,
+ RadarrSettings,
+ SonarrSettings,
+} from '@server/lib/settings';
import axios from 'axios';
import { Fragment, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
@@ -269,7 +273,7 @@ const SettingsServices = () => {
)}
{editLidarrModal.open && (
setEditLidarrModal({ open: false, lidarr: null })}
onSave={() => {
revalidateLidarr();
@@ -301,7 +305,11 @@ const SettingsServices = () => {
}
title={intl.formatMessage(messages.deleteServer, {
serverType:
- deleteServerModal.type === 'radarr' ? 'Radarr' : (deleteServerModal.type === 'sonarr' ? 'Sonarr' : 'Lidarr'),
+ deleteServerModal.type === 'radarr'
+ ? 'Radarr'
+ : deleteServerModal.type === 'sonarr'
+ ? 'Sonarr'
+ : 'Lidarr',
})}
>
{intl.formatMessage(messages.deleteserverconfirm)}
@@ -495,8 +503,7 @@ const SettingsServices = () => {
mediaType: intl.formatMessage(messages.mediaTypeSeries),
})}
/>
- ) : null
- )}
+ ) : null)}
{lidarrData.map((lidarr) => (