Change lidarr to artist instead of album
This commit is contained in:
parent
3383b553d5
commit
ea50a851f3
3 changed files with 9 additions and 14 deletions
|
@ -209,7 +209,7 @@
|
|||
"lidarr": {
|
||||
"wanted": "Wanted",
|
||||
"queued": "Queued",
|
||||
"albums": "Albums"
|
||||
"artists": "Artists"
|
||||
},
|
||||
"readarr": {
|
||||
"wanted": "Wanted",
|
||||
|
|
|
@ -9,23 +9,21 @@ export default function Component({ service }) {
|
|||
|
||||
const { widget } = service;
|
||||
|
||||
// album API endpoint can get massive, so we prevent calling if not included in fields see https://github.com/benphelps/homepage/discussions/1577
|
||||
const showAlbums = widget.fields?.includes('albums') || !widget.fields;
|
||||
const { data: albumsData, error: albumsError } = useWidgetAPI(widget, showAlbums ? "album" : "");
|
||||
const { data: artistsData, error: artistsError } = useWidgetAPI(widget, "artist");
|
||||
const { data: wantedData, error: wantedError } = useWidgetAPI(widget, "wanted/missing");
|
||||
const { data: queueData, error: queueError } = useWidgetAPI(widget, "queue/status");
|
||||
|
||||
if (albumsError || wantedError || queueError) {
|
||||
const finalError = albumsError ?? wantedError ?? queueError;
|
||||
if (artistsError || wantedError || queueError) {
|
||||
const finalError = artistsError ?? wantedError ?? queueError;
|
||||
return <Container service={service} error={finalError} />;
|
||||
}
|
||||
|
||||
if ((showAlbums && !albumsData) || !wantedData || !queueData) {
|
||||
if (!artistsData || !wantedData || !queueData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="lidarr.wanted" />
|
||||
<Block label="lidarr.queued" />
|
||||
<Block label="lidarr.albums" />
|
||||
<Block label="lidarr.artists" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
@ -34,7 +32,7 @@ export default function Component({ service }) {
|
|||
<Container service={service}>
|
||||
<Block label="lidarr.wanted" value={t("common.number", { value: wantedData.totalRecords })} />
|
||||
<Block label="lidarr.queued" value={t("common.number", { value: queueData.totalCount })} />
|
||||
{showAlbums && <Block label="lidarr.albums" value={t("common.number", { value: albumsData?.have })} />}
|
||||
<Block label="lidarr.artists" value={t("common.number", { value: artistsData.length })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,8 @@ const widget = {
|
|||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
album: {
|
||||
endpoint: "album",
|
||||
map: (data) => ({
|
||||
have: jsonArrayFilter(data, (item) => item?.statistics?.percentOfTracks === 100).length,
|
||||
}),
|
||||
artist: {
|
||||
endpoint: "artist",
|
||||
},
|
||||
"wanted/missing": {
|
||||
endpoint: "wanted/missing",
|
||||
|
|
Loading…
Add table
Reference in a new issue