🐛 Fix a small bug with the display of images

This commit is contained in:
ajnart
2022-08-11 17:04:43 +02:00
parent cf89141f82
commit 4f94999b07
4 changed files with 22 additions and 8 deletions

View File

@@ -135,7 +135,13 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
const [debounced, cancel] = useDebouncedValue(form.values.name, 250);
useEffect(() => {
if (form.values.name !== debounced || form.values.icon !== DEFAULT_ICON || form.values.type !== 'Other') return;
if (
form.values.name !== debounced ||
form.values.icon !== DEFAULT_ICON ||
form.values.type !== 'Other'
) {
return;
}
MatchIcon(form.values.name, form);
MatchService(form.values.name, form);
tryMatchPort(form.values.name, form);

View File

@@ -1,4 +1,4 @@
import { ActionIcon, Badge, Button, Group, Image, Stack, Text, Title } from '@mantine/core';
import { Badge, Button, Group, Image, Stack, Text, Title } from '@mantine/core';
import { IconDownload, IconExternalLink, IconPlayerPlay } from '@tabler/icons';
import { useState } from 'react';
import { useColorTheme } from '../../tools/color';
@@ -63,9 +63,11 @@ export function ReadarrMediaDisplay(props: any) {
if (!readarr) {
return null;
}
const baseUrl = new URL(readarr.url).origin;
const baseUrl = readarr.openedUrl
? new URL(readarr.openedUrl).origin
: new URL(readarr.url).origin;
// Remove '/' from the end of the lidarr url
const fullLink = `${baseUrl}${poster.url}`;
const fullLink = poster ? `${baseUrl}${poster.url}` : undefined;
// Return a movie poster containting the title and the description
return (
<MediaDisplay
@@ -93,7 +95,7 @@ export function LidarrMediaDisplay(props: any) {
if (!lidarr) {
return null;
}
const baseUrl = new URL(lidarr.url).origin;
const baseUrl = lidarr.openedUrl ? new URL(lidarr.openedUrl).origin : new URL(lidarr.url).origin;
// Remove '/' from the end of the lidarr url
const fullLink = poster ? `${baseUrl}${poster.url}` : undefined;
// Return a movie poster containting the title and the description

View File

@@ -11,7 +11,9 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
const { id, type } = req.query as { id: string; type: string };
const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
const service = config.services.find((service) => service.type === 'Overseerr' || service.type === 'Jellyseerr');
const service = config.services.find(
(service) => service.type === 'Overseerr' || service.type === 'Jellyseerr'
);
if (!id) {
return res.status(400).json({ error: 'No id provided' });
}
@@ -70,7 +72,9 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
const { seasons, type } = req.body as { seasons?: number[]; type: MediaType };
const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
const service = config.services.find((service) => service.type === 'Overseerr' || service.type === 'Jellyseerr');
const service = config.services.find(
(service) => service.type === 'Overseerr' || service.type === 'Jellyseerr'
);
if (!id) {
return res.status(400).json({ error: 'No id provided' });
}

View File

@@ -8,7 +8,9 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
const { query } = req.query;
const service = config.services.find((service) => service.type === 'Overseerr' || service.type === 'Jellyseerr');
const service = config.services.find(
(service) => service.type === 'Overseerr' || service.type === 'Jellyseerr'
);
// If query is an empty string, return an empty array
if (query === '' || query === undefined) {
return res.status(200).json([]);