diff --git a/src/components/widgets/unifi_console/unifi_console.jsx b/src/components/widgets/unifi_console/unifi_console.jsx index 3e3e135e7..af8fd4586 100644 --- a/src/components/widgets/unifi_console/unifi_console.jsx +++ b/src/components/widgets/unifi_console/unifi_console.jsx @@ -12,7 +12,7 @@ export default function Widget({ options }) { options.type = "unifi_console"; const { data: statsData, error: statsError } = useWidgetAPI(options, "stat/sites", { index: options.index }); - if (statsError || statsData?.error) { + if (statsError) { return (
diff --git a/src/utils/proxy/use-widget-api.js b/src/utils/proxy/use-widget-api.js index b196e62c4..05eb220ec 100644 --- a/src/utils/proxy/use-widget-api.js +++ b/src/utils/proxy/use-widget-api.js @@ -3,5 +3,11 @@ import useSWR from "swr"; import { formatProxyUrl } from "./api-helpers"; export default function useWidgetAPI(widget, ...options) { - return useSWR(formatProxyUrl(widget, ...options)); + const config = {}; + if (options?.refreshInterval) { + config.refreshInterval = options.refreshInterval; + } + const { data, error } = useSWR(formatProxyUrl(widget, ...options), config); + // make the data error the top-level error + return { data, error: data?.error ?? error } } diff --git a/src/widgets/adguard/component.jsx b/src/widgets/adguard/component.jsx index 3147ffcf8..bab969ad3 100644 --- a/src/widgets/adguard/component.jsx +++ b/src/widgets/adguard/component.jsx @@ -11,10 +11,10 @@ export default function Component({ service }) { const { data: adguardData, error: adguardError } = useWidgetAPI(widget, "stats"); - if (adguardError || adguardData?.error) { - const finalError = adguardError ?? adguardData.error; - return ; + if (adguardError) { + return ; } + if (!adguardData) { return ( diff --git a/src/widgets/authentik/component.jsx b/src/widgets/authentik/component.jsx index d4aa8dba7..84498db48 100644 --- a/src/widgets/authentik/component.jsx +++ b/src/widgets/authentik/component.jsx @@ -13,8 +13,8 @@ export default function Component({ service }) { const { data: loginsData, error: loginsError } = useWidgetAPI(widget, "login"); const { data: failedLoginsData, error: failedLoginsError } = useWidgetAPI(widget, "login_failed"); - if (usersError || usersData?.error || loginsError || loginsData?.error || failedLoginsError || failedLoginsData?.error) { - const finalError = usersError ?? usersData?.error ?? loginsError ?? loginsData?.error ?? failedLoginsError ?? failedLoginsData?.error; + if (usersError || loginsError || failedLoginsError) { + const finalError = usersError ?? loginsError ?? failedLoginsError; return ; } diff --git a/src/widgets/autobrr/component.jsx b/src/widgets/autobrr/component.jsx index d2769f0d4..3c1702436 100644 --- a/src/widgets/autobrr/component.jsx +++ b/src/widgets/autobrr/component.jsx @@ -13,8 +13,8 @@ export default function Component({ service }) { const { data: filtersData, error: filtersError } = useWidgetAPI(widget, "filters"); const { data: indexersData, error: indexersError } = useWidgetAPI(widget, "indexers"); - if (statsError || statsData?.error || filtersError || filtersData?.error || indexersError || indexersData?.error) { - const finalError = statsError ?? statsData?.error ?? filtersError ?? filtersData?.error ?? indexersError ?? indexersData?.error; + if (statsError || filtersError || indexersError) { + const finalError = statsError ?? filtersError ?? indexersError; return ; } diff --git a/src/widgets/bazarr/component.jsx b/src/widgets/bazarr/component.jsx index 070f82326..0537c180d 100644 --- a/src/widgets/bazarr/component.jsx +++ b/src/widgets/bazarr/component.jsx @@ -12,8 +12,8 @@ export default function Component({ service }) { const { data: episodesData, error: episodesError } = useWidgetAPI(widget, "episodes"); const { data: moviesData, error: moviesError } = useWidgetAPI(widget, "movies"); - if (moviesError || moviesData?.error || episodesError || episodesData?.error) { - const finalError = moviesError ?? moviesData?.error ?? episodesError ?? episodesData?.error; + if (moviesError || episodesError) { + const finalError = moviesError ?? episodesError; return ; } diff --git a/src/widgets/changedetectionio/component.jsx b/src/widgets/changedetectionio/component.jsx index ce29691f2..0a4ce8d2c 100644 --- a/src/widgets/changedetectionio/component.jsx +++ b/src/widgets/changedetectionio/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data, error } = useWidgetAPI(widget, "info"); - if (error || data?.error) { - const finalError = error ?? data.error; - return ; + if (error) { + return ; } const totalObserved = Object.keys(data).length; let diffsDetected = 0; diff --git a/src/widgets/coinmarketcap/component.jsx b/src/widgets/coinmarketcap/component.jsx index fa5844bdf..90b91a5ea 100644 --- a/src/widgets/coinmarketcap/component.jsx +++ b/src/widgets/coinmarketcap/component.jsx @@ -36,9 +36,8 @@ export default function Component({ service }) { ); } - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData || !dateRange) { diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx index 26371c814..a61cd7aa7 100644 --- a/src/widgets/emby/component.jsx +++ b/src/widgets/emby/component.jsx @@ -1,10 +1,10 @@ -import useSWR from "swr"; import { useTranslation } from "next-i18next"; import { BsVolumeMuteFill, BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs"; import { MdOutlineSmartDisplay } from "react-icons/md"; -import { formatProxyUrl, formatProxyUrlWithSegments } from "utils/proxy/api-helpers"; import Container from "components/services/widget/container"; +import { formatProxyUrlWithSegments } from "utils/proxy/api-helpers"; +import useWidgetAPI from "utils/proxy/use-widget-api"; function ticksToTime(ticks) { const milliseconds = ticks / 10000; @@ -157,7 +157,7 @@ export default function Component({ service }) { data: sessionsData, error: sessionsError, mutate: sessionMutate, - } = useSWR(formatProxyUrl(widget, "Sessions"), { + } = useWidgetAPI(widget, "Sessions", { refreshInterval: 5000, }); @@ -171,9 +171,8 @@ export default function Component({ service }) { }); } - if (sessionsError || sessionsData?.error) { - const finalError = sessionsError ?? sessionsData.error; - return ; + if (sessionsError) { + return ; } if (!sessionsData) { diff --git a/src/widgets/gotify/component.jsx b/src/widgets/gotify/component.jsx index cedc3f84a..7cd5c1358 100644 --- a/src/widgets/gotify/component.jsx +++ b/src/widgets/gotify/component.jsx @@ -9,8 +9,8 @@ export default function Component({ service }) { const { data: messagesData, error: messagesError } = useWidgetAPI(widget, "message"); const { data: clientsData, error: clientsError } = useWidgetAPI(widget, "client"); - if (appsError || appsData?.error || messagesError || messagesData?.error || clientsError || clientsData?.error) { - const finalError = appsError ?? appsData?.error ?? messagesError ?? messagesData?.error ?? clientsError ?? clientsData?.error; + if (appsError || messagesError || clientsError) { + const finalError = appsError ?? messagesError ?? clientsError; return ; } diff --git a/src/widgets/homebridge/component.jsx b/src/widgets/homebridge/component.jsx index 3f1dc5dad..a1e2f2e1d 100644 --- a/src/widgets/homebridge/component.jsx +++ b/src/widgets/homebridge/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: homebridgeData, error: homebridgeError } = useWidgetAPI(widget, "info"); - if (homebridgeError || homebridgeData?.error) { - const finalError = homebridgeError ?? homebridgeData.error; - return ; + if (homebridgeError) { + return ; } if (!homebridgeData) { diff --git a/src/widgets/jackett/component.jsx b/src/widgets/jackett/component.jsx index e9fcd95a8..b70cbd954 100644 --- a/src/widgets/jackett/component.jsx +++ b/src/widgets/jackett/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: indexersData, error: indexersError } = useWidgetAPI(widget, "indexers"); - if (indexersError || indexersData?.error) { - const finalError = indexersError ?? indexersData.error; - return ; + if (indexersError) { + return ; } if (!indexersData) { diff --git a/src/widgets/jellyseerr/component.jsx b/src/widgets/jellyseerr/component.jsx index aece8560f..a129909eb 100644 --- a/src/widgets/jellyseerr/component.jsx +++ b/src/widgets/jellyseerr/component.jsx @@ -7,9 +7,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "request/count"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData) { diff --git a/src/widgets/lidarr/component.jsx b/src/widgets/lidarr/component.jsx index 5951e094c..b612ae32e 100644 --- a/src/widgets/lidarr/component.jsx +++ b/src/widgets/lidarr/component.jsx @@ -13,8 +13,8 @@ export default function Component({ service }) { const { data: wantedData, error: wantedError } = useWidgetAPI(widget, "wanted/missing"); const { data: queueData, error: queueError } = useWidgetAPI(widget, "queue/status"); - if (albumsError || albumsData?.error || wantedError || wantedData?.error || queueError || queueData?.error) { - const finalError = albumsError ?? albumsData?.error ?? wantedError ?? wantedData?.error ?? queueError ?? queueData?.error; + if (albumsError || wantedError || queueError) { + const finalError = albumsError ?? wantedError ?? queueError; return ; } diff --git a/src/widgets/mastodon/component.jsx b/src/widgets/mastodon/component.jsx index 477d648ec..fd4f0ece6 100644 --- a/src/widgets/mastodon/component.jsx +++ b/src/widgets/mastodon/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "instance"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData) { diff --git a/src/widgets/navidrome/component.jsx b/src/widgets/navidrome/component.jsx index f4f3e6721..e45ac6555 100644 --- a/src/widgets/navidrome/component.jsx +++ b/src/widgets/navidrome/component.jsx @@ -26,8 +26,8 @@ export default function Component({ service }) { const { data: navidromeData, error: navidromeError } = useWidgetAPI(widget, "getNowPlaying"); - if (navidromeError || navidromeData?.error || navidromeData?.["subsonic-response"]?.error) { - return ; + if (navidromeError || navidromeData?.["subsonic-response"]?.error) { + return ; } if (!navidromeData) { diff --git a/src/widgets/nzbget/component.jsx b/src/widgets/nzbget/component.jsx index 92408982a..b33e0830a 100644 --- a/src/widgets/nzbget/component.jsx +++ b/src/widgets/nzbget/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: statusData, error: statusError } = useWidgetAPI(widget, "status"); - if (statusError || statusData?.error) { - const finalError = statusError ?? statusData.error; - return ; + if (statusError) { + return ; } if (!statusData) { diff --git a/src/widgets/ombi/component.jsx b/src/widgets/ombi/component.jsx index a5a0a0b73..722d5c457 100644 --- a/src/widgets/ombi/component.jsx +++ b/src/widgets/ombi/component.jsx @@ -7,9 +7,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "Request/count"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData) { diff --git a/src/widgets/overseerr/component.jsx b/src/widgets/overseerr/component.jsx index f0269b4f1..6f5ae8ffe 100644 --- a/src/widgets/overseerr/component.jsx +++ b/src/widgets/overseerr/component.jsx @@ -7,9 +7,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "request/count"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData) { diff --git a/src/widgets/pihole/component.jsx b/src/widgets/pihole/component.jsx index cb77cc2b6..f213ac6db 100644 --- a/src/widgets/pihole/component.jsx +++ b/src/widgets/pihole/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: piholeData, error: piholeError } = useWidgetAPI(widget, "api.php"); - if (piholeError || piholeData?.error) { - const finalError = piholeError ?? piholeData.error; - return ; + if (piholeError) { + return ; } if (!piholeData) { diff --git a/src/widgets/plex/component.jsx b/src/widgets/plex/component.jsx index cf6d705cf..6fe15bd57 100644 --- a/src/widgets/plex/component.jsx +++ b/src/widgets/plex/component.jsx @@ -1,22 +1,20 @@ -import useSWR from "swr"; import { useTranslation } from "next-i18next"; import Block from "components/services/widget/block"; import Container from "components/services/widget/container"; -import { formatProxyUrl } from "utils/proxy/api-helpers"; +import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; - const { data: plexData, error: plexAPIError } = useSWR(formatProxyUrl(widget, "unified"), { + const { data: plexData, error: plexAPIError } = useWidgetAPI(widget, "unified", { refreshInterval: 5000, }); - if (plexAPIError || plexData?.error) { - const finalError = plexAPIError ?? plexData.error; - return ; + if (plexAPIError) { + return ; } if (!plexData) { diff --git a/src/widgets/plex/proxy.js b/src/widgets/plex/proxy.js index c016023dd..36b7a268e 100644 --- a/src/widgets/plex/proxy.js +++ b/src/widgets/plex/proxy.js @@ -67,7 +67,7 @@ export default async function plexProxyHandler(req, res) { let [status, apiData] = await fetchFromPlexAPI("/status/sessions", widget); if (status !== 200) { - return res.status(status).json({error: {message: "HTTP error communicating with Plex API", data: apiData}}); + return res.status(status).json({error: {message: "HTTP error communicating with Plex API", data: Buffer.from(apiData).toString()}}); } if (apiData && apiData.MediaContainer) { diff --git a/src/widgets/portainer/component.jsx b/src/widgets/portainer/component.jsx index 87c173dd8..ccc26b7f6 100644 --- a/src/widgets/portainer/component.jsx +++ b/src/widgets/portainer/component.jsx @@ -13,9 +13,8 @@ export default function Component({ service }) { all: 1, }); - if (containersError || containersData?.error) { - const finalError = containersError ?? containersData.error; - return ; + if (containersError) { + return ; } if (!containersData) { diff --git a/src/widgets/prowlarr/component.jsx b/src/widgets/prowlarr/component.jsx index 6649fdefd..890679e52 100644 --- a/src/widgets/prowlarr/component.jsx +++ b/src/widgets/prowlarr/component.jsx @@ -8,8 +8,8 @@ export default function Component({ service }) { const { data: indexersData, error: indexersError } = useWidgetAPI(widget, "indexer"); const { data: grabsData, error: grabsError } = useWidgetAPI(widget, "indexerstats"); - if (indexersError || indexersData?.error || grabsError || grabsData?.error) { - const finalError = indexersError ?? indexersData?.error ?? grabsError ?? grabsData?.error; + if (indexersError || grabsError) { + const finalError = indexersError ?? grabsError; return ; } diff --git a/src/widgets/proxmox/component.jsx b/src/widgets/proxmox/component.jsx index 79d2d8814..1d384b546 100644 --- a/src/widgets/proxmox/component.jsx +++ b/src/widgets/proxmox/component.jsx @@ -15,9 +15,8 @@ export default function Component({ service }) { const { data: clusterData, error: clusterError } = useWidgetAPI(widget, "cluster/resources"); - if (clusterError || clusterData?.error) { - const finalError = clusterError ?? clusterData.error; - return ; + if (clusterError) { + return ; } if (!clusterData || !clusterData.data) { diff --git a/src/widgets/pyload/component.jsx b/src/widgets/pyload/component.jsx index 958733c31..3bb4b0c45 100644 --- a/src/widgets/pyload/component.jsx +++ b/src/widgets/pyload/component.jsx @@ -9,8 +9,8 @@ export default function Component({ service }) { const { widget } = service; const { data: pyloadData, error: pyloadError } = useWidgetAPI(widget, "status"); - if (pyloadError || pyloadData?.error) { - return ; + if (pyloadError) { + return ; } if (!pyloadData) { diff --git a/src/widgets/qbittorrent/component.jsx b/src/widgets/qbittorrent/component.jsx index 541032a1f..3abc933da 100644 --- a/src/widgets/qbittorrent/component.jsx +++ b/src/widgets/qbittorrent/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: torrentData, error: torrentError } = useWidgetAPI(widget, "torrents/info"); - if (torrentError || torrentData?.error) { - const finalError = torrentError ?? torrentData.error; - return ; + if (torrentError) { + return ; } if (!torrentData) { diff --git a/src/widgets/radarr/component.jsx b/src/widgets/radarr/component.jsx index 679ce4fd0..f2620b789 100644 --- a/src/widgets/radarr/component.jsx +++ b/src/widgets/radarr/component.jsx @@ -8,8 +8,8 @@ export default function Component({ service }) { const { data: moviesData, error: moviesError } = useWidgetAPI(widget, "movie"); const { data: queuedData, error: queuedError } = useWidgetAPI(widget, "queue/status"); - if (moviesError || moviesData?.error || queuedError || queuedData?.error) { - const finalError = moviesError ?? moviesData?.error ?? queuedError ?? queuedData?.error; + if (moviesError || queuedError) { + const finalError = moviesError ?? queuedError; return ; } diff --git a/src/widgets/readarr/component.jsx b/src/widgets/readarr/component.jsx index ddf2dfd7c..4eee11f4f 100644 --- a/src/widgets/readarr/component.jsx +++ b/src/widgets/readarr/component.jsx @@ -13,8 +13,8 @@ export default function Component({ service }) { const { data: wantedData, error: wantedError } = useWidgetAPI(widget, "wanted/missing"); const { data: queueData, error: queueError } = useWidgetAPI(widget, "queue/status"); - if (booksError || booksData?.error || wantedError || wantedData?.error || queueError || queueData?.error) { - const finalError = booksError ?? booksData?.error ?? wantedError ?? wantedData?.error ?? queueError ?? queueData?.error; + if (booksError || wantedError || queueError) { + const finalError = booksError ?? wantedError ?? queueError; return ; } diff --git a/src/widgets/rutorrent/component.jsx b/src/widgets/rutorrent/component.jsx index 4f7340f58..ef3a278f1 100644 --- a/src/widgets/rutorrent/component.jsx +++ b/src/widgets/rutorrent/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: statusData, error: statusError } = useWidgetAPI(widget); - if (statusError || statusData?.error) { - const finalError = statusError ?? statusData.error; - return ; + if (statusError) { + return ; } if (!statusData) { diff --git a/src/widgets/sabnzbd/component.jsx b/src/widgets/sabnzbd/component.jsx index db49160b2..b0cdb9518 100644 --- a/src/widgets/sabnzbd/component.jsx +++ b/src/widgets/sabnzbd/component.jsx @@ -21,9 +21,8 @@ export default function Component({ service }) { const { data: queueData, error: queueError } = useWidgetAPI(widget, "queue"); - if (queueError || queueData?.error) { - const finalError = queueError ?? queueData.error; - return ; + if (queueError) { + return ; } if (!queueData) { diff --git a/src/widgets/sonarr/component.jsx b/src/widgets/sonarr/component.jsx index 28751eb66..14dd33287 100644 --- a/src/widgets/sonarr/component.jsx +++ b/src/widgets/sonarr/component.jsx @@ -9,8 +9,8 @@ export default function Component({ service }) { const { data: queuedData, error: queuedError } = useWidgetAPI(widget, "queue"); const { data: seriesData, error: seriesError } = useWidgetAPI(widget, "series"); - if (wantedError || wantedData?.error || queuedError || queuedData?.error || seriesError || seriesData?.error) { - const finalError = wantedError ?? wantedData?.error ?? queuedError ?? queuedData?.error ?? seriesError ?? seriesData?.error; + if (wantedError || queuedError || seriesError) { + const finalError = wantedError ?? queuedError ?? seriesError; return ; } diff --git a/src/widgets/speedtest/component.jsx b/src/widgets/speedtest/component.jsx index b8bc7fdd6..3067dbf3d 100644 --- a/src/widgets/speedtest/component.jsx +++ b/src/widgets/speedtest/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: speedtestData, error: speedtestError } = useWidgetAPI(widget, "speedtest/latest"); - if (speedtestError || speedtestData?.error) { - const finalError = speedtestError ?? speedtestData.error; - return ; + if (speedtestError) { + return ; } if (!speedtestData) { diff --git a/src/widgets/strelaysrv/component.jsx b/src/widgets/strelaysrv/component.jsx index 3366ffc29..f58f8830a 100644 --- a/src/widgets/strelaysrv/component.jsx +++ b/src/widgets/strelaysrv/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "status"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } if (!statsData) { diff --git a/src/widgets/tautulli/component.jsx b/src/widgets/tautulli/component.jsx index d77f2b1e4..44b1eb6db 100644 --- a/src/widgets/tautulli/component.jsx +++ b/src/widgets/tautulli/component.jsx @@ -1,11 +1,10 @@ /* eslint-disable camelcase */ -import useSWR from "swr"; import { useTranslation } from "next-i18next"; import { BsFillPlayFill, BsPauseFill, BsCpu, BsFillCpuFill } from "react-icons/bs"; import { MdOutlineSmartDisplay, MdSmartDisplay } from "react-icons/md"; -import { formatProxyUrl } from "utils/proxy/api-helpers"; import Container from "components/services/widget/container"; +import useWidgetAPI from "utils/proxy/use-widget-api"; function millisecondsToTime(milliseconds) { const seconds = Math.floor((milliseconds / 1000) % 60); @@ -119,13 +118,12 @@ export default function Component({ service }) { const { widget } = service; - const { data: activityData, error: activityError } = useSWR(formatProxyUrl(widget, "get_activity"), { + const { data: activityData, error: activityError } = useWidgetAPI(widget, "get_activity", { refreshInterval: 5000, }); - if (activityError || activityData?.error) { - const finalError = activityError ?? activityData.error; - return ; + if (activityError) { + return ; } if (!activityData) { diff --git a/src/widgets/traefik/component.jsx b/src/widgets/traefik/component.jsx index bee59c290..7739e62a1 100644 --- a/src/widgets/traefik/component.jsx +++ b/src/widgets/traefik/component.jsx @@ -7,9 +7,8 @@ export default function Component({ service }) { const { data: traefikData, error: traefikError } = useWidgetAPI(widget, "overview"); - if (traefikError || traefikData?.error) { - const finalError = traefikError ?? traefikData.error; - return ; + if (traefikError) { + return ; } if (!traefikData) { diff --git a/src/widgets/transmission/component.jsx b/src/widgets/transmission/component.jsx index 6cc8efe6e..7de276c28 100644 --- a/src/widgets/transmission/component.jsx +++ b/src/widgets/transmission/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: torrentData, error: torrentError } = useWidgetAPI(widget); - if (torrentError || torrentData?.error) { - const finalError = torrentError ?? torrentData.error; - return ; + if (torrentError) { + return ; } if (!torrentData) { diff --git a/src/widgets/truenas/component.jsx b/src/widgets/truenas/component.jsx index fd2fdbe79..70f917ab4 100644 --- a/src/widgets/truenas/component.jsx +++ b/src/widgets/truenas/component.jsx @@ -41,8 +41,8 @@ export default function Component({ service }) { const { data: alertData, error: alertError } = useWidgetAPI(widget, "alerts"); const { data: statusData, error: statusError } = useWidgetAPI(widget, "status"); - if (alertError || alertData?.error || statusError || statusData?.error) { - const finalError = alertError ?? alertData?.error ?? statusError ?? statusData?.error; + if (alertError || statusError) { + const finalError = alertError ?? statusError; return ; } diff --git a/src/widgets/tubearchivist/component.jsx b/src/widgets/tubearchivist/component.jsx index 503fb0faa..b1b310d77 100644 --- a/src/widgets/tubearchivist/component.jsx +++ b/src/widgets/tubearchivist/component.jsx @@ -14,8 +14,8 @@ export default function Component({ service }) { const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "channels"); const { data: playlistsData, error: playlistsError } = useWidgetAPI(widget, "playlists"); - if (downloadsError || downloadsData?.error || videosError || videosData?.error || channelsError || channelsData?.error || playlistsError || playlistsData?.error) { - const finalError = downloadsError ?? downloadsData?.error ?? videosError ?? videosData?.error ?? channelsError ?? channelsData?.error ?? playlistsError ?? playlistsData?.error; + if (downloadsError || videosError || channelsError || playlistsError) { + const finalError = downloadsError ?? videosError ?? channelsError ?? playlistsError; return ; } diff --git a/src/widgets/unifi/component.jsx b/src/widgets/unifi/component.jsx index ea161d674..6df43dfdb 100644 --- a/src/widgets/unifi/component.jsx +++ b/src/widgets/unifi/component.jsx @@ -11,9 +11,8 @@ export default function Component({ service }) { const { data: statsData, error: statsError } = useWidgetAPI(widget, "stat/sites"); - if (statsError || statsData?.error) { - const finalError = statsError ?? statsData.error; - return ; + if (statsError) { + return ; } const defaultSite = statsData?.data?.find(s => s.name === "default"); diff --git a/src/widgets/watchtower/component.jsx b/src/widgets/watchtower/component.jsx index 2f683c1db..3550e3f43 100644 --- a/src/widgets/watchtower/component.jsx +++ b/src/widgets/watchtower/component.jsx @@ -12,9 +12,8 @@ export default function Component({ service }) { const { data: watchData, error: watchError } = useWidgetAPI(widget, "watchtower"); - if (watchError || watchData?.error) { - const finalError = watchError ?? watchData?.error; - return ; + if (watchError) { + return ; } if (!watchData) {