From eaf7ba608b5f9707950ec5d7f16fbcd58e84d099 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Sun, 12 Mar 2023 16:50:28 -0700
Subject: [PATCH] Fix blocks for emby/jellyfin, support enable/disable
---
public/locales/en/common.json | 6 +-
src/utils/config/service-helpers.js | 8 +-
src/widgets/emby/component.jsx | 173 ++++++++++++++--------------
3 files changed, 101 insertions(+), 86 deletions(-)
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index a9d6ed34..db5ffe46 100755
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -72,7 +72,11 @@
"playing": "Playing",
"transcoding": "Transcoding",
"bitrate": "Bitrate",
- "no_active": "No Active Streams"
+ "no_active": "No Active Streams",
+ "movies": "Movies",
+ "series": "Series",
+ "episodes": "Episodes",
+ "songs": "Songs"
},
"flood": {
"download": "Download",
diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js
index 49401ee6..317c0f3c 100644
--- a/src/utils/config/service-helpers.js
+++ b/src/utils/config/service-helpers.js
@@ -247,7 +247,9 @@ export function cleanServiceGroups(groups) {
namespace, // kubernetes widget
app,
podSelector,
- wan // opnsense widget
+ wan, // opnsense widget,
+ enableBlocks, // emby/jellyfin
+ enableNowPlaying
} = cleanedService.widget;
const fieldsList = typeof fields === 'string' ? JSON.parse(fields) : fields;
@@ -278,6 +280,10 @@ export function cleanServiceGroups(groups) {
if (type === "opnsense") {
if (wan) cleanedService.widget.wan = wan;
}
+ if (type === "emby" || type === "jellyfin") {
+ if (enableBlocks) cleanedService.widget.enableBlocks = enableBlocks === 'true';
+ if (enableNowPlaying) cleanedService.widget.enableNowPlaying = enableNowPlaying === 'true';
+ }
}
return cleanedService;
diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx
index a8d4f6b2..3f70a79d 100644
--- a/src/widgets/emby/component.jsx
+++ b/src/widgets/emby/component.jsx
@@ -149,6 +149,33 @@ function SessionEntry({ playCommand, session }) {
);
}
+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'
+
+ if (!countData) {
+ return (
+