diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx index a61cd7aa..e7d65a34 100644 --- a/src/widgets/emby/component.jsx +++ b/src/widgets/emby/component.jsx @@ -2,6 +2,7 @@ import { useTranslation } from "next-i18next"; import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs"; import { MdOutlineSmartDisplay } from "react-icons/md"; +import Block from "components/services/widget/block"; import Container from "components/services/widget/container"; import { formatProxyUrlWithSegments } from "utils/proxy/api-helpers"; import useWidgetAPI from "utils/proxy/use-widget-api"; @@ -161,18 +162,45 @@ export default function Component({ service }) { refreshInterval: 5000, }); + const { + data: countData, + error: countError, + } = useWidgetAPI(widget, "Count", { + refreshInterval: 60000,}); + async function handlePlayCommand(session, command) { const url = formatProxyUrlWithSegments(widget, "PlayControl", { sessionId: session.Id, command, }); await fetch(url).then(() => { - sessionMutate(); + sessionMutate; }); } - if (sessionsError) { - return ; + if (sessionsError || countError) { + return ; + } + + if (!sessionsData && countData) { + return ( + <> + + + + + + +
+
+ - +
+
+ - +
+
+ + ); } if (!sessionsData) { @@ -200,8 +228,15 @@ export default function Component({ service }) { return 0; }); - if (playing.length === 0) { + if (playing.length === 0 && countData) { return ( + <> + + + + + +
{t("emby.no_active")} @@ -210,22 +245,39 @@ export default function Component({ service }) { -
+ ); } - if (playing.length === 1) { + if (playing.length === 1 && countData) { const session = playing[0]; return ( + <> + + + + + +
handlePlayCommand(currentSession, command)} session={session} />
+ ); } + if (countData && playing.length === -1) return ( + <> + + + + + +
{playing.map((session) => ( ))}
+ ); } diff --git a/src/widgets/emby/widget.js b/src/widgets/emby/widget.js index 27fc749b..bbf13a30 100644 --- a/src/widgets/emby/widget.js +++ b/src/widgets/emby/widget.js @@ -8,6 +8,15 @@ const widget = { Sessions: { endpoint: "Sessions", }, + Count: { + endpoint: "Items/Counts", + segments: [ + "MovieCount", + "SeriesCount", + "EpisodeCount", + "SongCount" + ] + }, PlayControl: { method: "POST", endpoint: "Sessions/{sessionId}/Playing/{command}",