From 65b57ea7d021f25f0ee707a6ee3b1c7cf2d76779 Mon Sep 17 00:00:00 2001 From: AdamWHY2K <68286215+AdamWHY2K@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:16:18 +0100 Subject: [PATCH] feat: add books field to jellyfin widget --- docs/widgets/services/jellyfin.md | 2 +- public/locales/en/common.json | 3 ++- src/widgets/emby/component.jsx | 13 +++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/widgets/services/jellyfin.md b/docs/widgets/services/jellyfin.md index b6724a15..cd530bcd 100644 --- a/docs/widgets/services/jellyfin.md +++ b/docs/widgets/services/jellyfin.md @@ -7,7 +7,7 @@ Learn more about [Jellyfin](https://github.com/jellyfin/jellyfin). You can create an API key from inside Jellyfin at `Settings > Advanced > Api Keys`. -As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option. +As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs", "books"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option. ```yaml widget: diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 384f44be..a61f67d7 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -105,7 +105,8 @@ "movies": "Movies", "series": "Series", "episodes": "Episodes", - "songs": "Songs" + "songs": "Songs", + "books": "Books" }, "esphome": { "offline": "Offline", diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx index 6f66d1dc..a86ebf93 100644 --- a/src/widgets/emby/component.jsx +++ b/src/widgets/emby/component.jsx @@ -175,26 +175,31 @@ function SessionEntry({ playCommand, session, enableUser, showEpisodeNumber }) { function CountBlocks({ service, countData }) { const { t } = useTranslation(); // allows filtering - // eslint-disable-next-line no-param-reassign - if (service.widget?.type === "jellyfin") service.widget.type = "emby"; + const isJellyfin = service.widget?.type === "jellyfin"; + // Create a new service object instead of modifying the original + const modifiedService = isJellyfin + ? { ...service, widget: { ...service.widget, type: "emby" }} + : service; if (!countData) { return ( - + + {isJellyfin && } ); } return ( - + + {isJellyfin && } ); }