mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-10-31 14:34:00 +00: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 { DateTime } from "luxon"; | ||||
| import { useTranslation } from "next-i18next"; | ||||
| @ -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 | ||||
| @ -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) { | ||||
| @ -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" | ||||
|               /> | ||||
|             ); | ||||
|  | ||||
| @ -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, | ||||
| @ -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}` }} />; | ||||
| } | ||||
|  | ||||
| @ -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", { | ||||
| @ -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}` }} />; | ||||
| } | ||||
|  | ||||
| @ -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, | ||||
| @ -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}` }} />; | ||||
| } | ||||
|  | ||||
| @ -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, | ||||
| @ -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}` }} />; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 shamoon
						shamoon