Skip to content

Commit

Permalink
Fix: Respect hideErrors for Calendar widget (#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon authored Oct 30, 2023
1 parent 654f16d commit 5512d05
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/widgets/calendar/component.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from "react";
import { useEffect, useMemo, useState, useContext } from "react";
import dynamic from "next/dynamic";
import { DateTime } from "luxon";
import { useTranslation } from "next-i18next";
Expand All @@ -7,6 +7,7 @@ import Monthly from "./monthly";
import Agenda from "./agenda";

import Container from "components/services/widget/container";
import { SettingsContext } from "utils/contexts/settings";

const colorVariants = {
// https://tailwindcss.com/docs/content-configuration#dynamic-class-names
Expand Down Expand Up @@ -40,6 +41,7 @@ export default function Component({ service }) {
const { i18n } = useTranslation();
const [showDate, setShowDate] = useState(null);
const currentDate = DateTime.now().setLocale(i18n.language).startOf("day");
const { settings } = useContext(SettingsContext);

useEffect(() => {
if (!showDate) {
Expand Down Expand Up @@ -85,6 +87,7 @@ export default function Component({ service }) {
key={key}
config={integration.widget}
params={params}
hideErrors={settings.hideErrors}
className="fixed bottom-0 left-0 bg-red-500 w-screen h-12"
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/calendar/integrations/lidarr.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
import { EventContext } from "../../../utils/contexts/calendar";
import Error from "../../../components/services/widget/error";

export default function Integration({ config, params }) {
export default function Integration({ config, params, hideErrors = false }) {
const { setEvents } = useContext(EventContext);
const { data: lidarrData, error: lidarrError } = useWidgetAPI(config, "calendar", {
...params,
Expand Down Expand Up @@ -36,5 +36,5 @@ export default function Integration({ config, params }) {
}, [lidarrData, lidarrError, config, setEvents]);

const error = lidarrError ?? lidarrData?.error;
return error && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
}
4 changes: 2 additions & 2 deletions src/widgets/calendar/integrations/radarr.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
import { EventContext } from "../../../utils/contexts/calendar";
import Error from "../../../components/services/widget/error";

export default function Integration({ config, params }) {
export default function Integration({ config, params, hideErrors = false }) {
const { t } = useTranslation();
const { setEvents } = useContext(EventContext);
const { data: radarrData, error: radarrError } = useWidgetAPI(config, "calendar", {
Expand Down Expand Up @@ -52,5 +52,5 @@ export default function Integration({ config, params }) {
}, [radarrData, radarrError, config, setEvents, t]);

const error = radarrError ?? radarrData?.error;
return error && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
}
4 changes: 2 additions & 2 deletions src/widgets/calendar/integrations/readarr.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
import { EventContext } from "../../../utils/contexts/calendar";
import Error from "../../../components/services/widget/error";

export default function Integration({ config, params }) {
export default function Integration({ config, params, hideErrors = false }) {
const { setEvents } = useContext(EventContext);
const { data: readarrData, error: readarrError } = useWidgetAPI(config, "calendar", {
...params,
Expand Down Expand Up @@ -37,5 +37,5 @@ export default function Integration({ config, params }) {
}, [readarrData, readarrError, config, setEvents]);

const error = readarrError ?? readarrData?.error;
return error && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
}
4 changes: 2 additions & 2 deletions src/widgets/calendar/integrations/sonarr.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
import { EventContext } from "../../../utils/contexts/calendar";
import Error from "../../../components/services/widget/error";

export default function Integration({ config, params }) {
export default function Integration({ config, params, hideErrors = false }) {
const { setEvents } = useContext(EventContext);
const { data: sonarrData, error: sonarrError } = useWidgetAPI(config, "calendar", {
...params,
Expand Down Expand Up @@ -38,5 +38,5 @@ export default function Integration({ config, params }) {
}, [sonarrData, sonarrError, config, setEvents]);

const error = sonarrError ?? sonarrData?.error;
return error && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
}

0 comments on commit 5512d05

Please sign in to comment.