mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-04 14:33:41 +01:00
Fix: Respect hideErrors for Calendar widget (#2259)
This commit is contained in:
parent
654f16dbb5
commit
5512d05f00
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState, useContext } from "react";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
@ -7,6 +7,7 @@ import Monthly from "./monthly";
|
|||||||
import Agenda from "./agenda";
|
import Agenda from "./agenda";
|
||||||
|
|
||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
|
import { SettingsContext } from "utils/contexts/settings";
|
||||||
|
|
||||||
const colorVariants = {
|
const colorVariants = {
|
||||||
// https://tailwindcss.com/docs/content-configuration#dynamic-class-names
|
// https://tailwindcss.com/docs/content-configuration#dynamic-class-names
|
||||||
@ -40,6 +41,7 @@ export default function Component({ service }) {
|
|||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const [showDate, setShowDate] = useState(null);
|
const [showDate, setShowDate] = useState(null);
|
||||||
const currentDate = DateTime.now().setLocale(i18n.language).startOf("day");
|
const currentDate = DateTime.now().setLocale(i18n.language).startOf("day");
|
||||||
|
const { settings } = useContext(SettingsContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showDate) {
|
if (!showDate) {
|
||||||
@ -85,6 +87,7 @@ export default function Component({ service }) {
|
|||||||
key={key}
|
key={key}
|
||||||
config={integration.widget}
|
config={integration.widget}
|
||||||
params={params}
|
params={params}
|
||||||
|
hideErrors={settings.hideErrors}
|
||||||
className="fixed bottom-0 left-0 bg-red-500 w-screen h-12"
|
className="fixed bottom-0 left-0 bg-red-500 w-screen h-12"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
|||||||
import { EventContext } from "../../../utils/contexts/calendar";
|
import { EventContext } from "../../../utils/contexts/calendar";
|
||||||
import Error from "../../../components/services/widget/error";
|
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 { setEvents } = useContext(EventContext);
|
||||||
const { data: lidarrData, error: lidarrError } = useWidgetAPI(config, "calendar", {
|
const { data: lidarrData, error: lidarrError } = useWidgetAPI(config, "calendar", {
|
||||||
...params,
|
...params,
|
||||||
@ -36,5 +36,5 @@ export default function Integration({ config, params }) {
|
|||||||
}, [lidarrData, lidarrError, config, setEvents]);
|
}, [lidarrData, lidarrError, config, setEvents]);
|
||||||
|
|
||||||
const error = lidarrError ?? lidarrData?.error;
|
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}` }} />;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
|||||||
import { EventContext } from "../../../utils/contexts/calendar";
|
import { EventContext } from "../../../utils/contexts/calendar";
|
||||||
import Error from "../../../components/services/widget/error";
|
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 { t } = useTranslation();
|
||||||
const { setEvents } = useContext(EventContext);
|
const { setEvents } = useContext(EventContext);
|
||||||
const { data: radarrData, error: radarrError } = useWidgetAPI(config, "calendar", {
|
const { data: radarrData, error: radarrError } = useWidgetAPI(config, "calendar", {
|
||||||
@ -52,5 +52,5 @@ export default function Integration({ config, params }) {
|
|||||||
}, [radarrData, radarrError, config, setEvents, t]);
|
}, [radarrData, radarrError, config, setEvents, t]);
|
||||||
|
|
||||||
const error = radarrError ?? radarrData?.error;
|
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}` }} />;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
|||||||
import { EventContext } from "../../../utils/contexts/calendar";
|
import { EventContext } from "../../../utils/contexts/calendar";
|
||||||
import Error from "../../../components/services/widget/error";
|
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 { setEvents } = useContext(EventContext);
|
||||||
const { data: readarrData, error: readarrError } = useWidgetAPI(config, "calendar", {
|
const { data: readarrData, error: readarrError } = useWidgetAPI(config, "calendar", {
|
||||||
...params,
|
...params,
|
||||||
@ -37,5 +37,5 @@ export default function Integration({ config, params }) {
|
|||||||
}, [readarrData, readarrError, config, setEvents]);
|
}, [readarrData, readarrError, config, setEvents]);
|
||||||
|
|
||||||
const error = readarrError ?? readarrData?.error;
|
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}` }} />;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
|||||||
import { EventContext } from "../../../utils/contexts/calendar";
|
import { EventContext } from "../../../utils/contexts/calendar";
|
||||||
import Error from "../../../components/services/widget/error";
|
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 { setEvents } = useContext(EventContext);
|
||||||
const { data: sonarrData, error: sonarrError } = useWidgetAPI(config, "calendar", {
|
const { data: sonarrData, error: sonarrError } = useWidgetAPI(config, "calendar", {
|
||||||
...params,
|
...params,
|
||||||
@ -38,5 +38,5 @@ export default function Integration({ config, params }) {
|
|||||||
}, [sonarrData, sonarrError, config, setEvents]);
|
}, [sonarrData, sonarrError, config, setEvents]);
|
||||||
|
|
||||||
const error = sonarrError ?? sonarrData?.error;
|
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}` }} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user