mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 15:05:48 +01:00
✨ Invalidate queries
This commit adds the functionality of query invalidation - when a config is created - when the calendar options are changed It also makes it so the calendar doesn't update if the widget is currently being edited
This commit is contained in:
@@ -10,6 +10,7 @@ import { IWidget } from '../widgets';
|
||||
import { CalendarDay } from './CalendarDay';
|
||||
import { getBgColorByDateAndTheme } from './bg-calculator';
|
||||
import { MediasType } from './type';
|
||||
import { useEditModeStore } from '../../components/Dashboard/Views/useEditModeStore';
|
||||
|
||||
const definition = defineWidget({
|
||||
id: 'calendar',
|
||||
@@ -52,10 +53,15 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
||||
const { colorScheme } = useMantineTheme();
|
||||
const { name: configName } = useConfigContext();
|
||||
const [month, setMonth] = useState(new Date());
|
||||
const isEditMode = useEditModeStore((x) => x.enabled);
|
||||
|
||||
const { data: medias } = useQuery({
|
||||
queryKey: ['calendar/medias', { month: month.getMonth(), year: month.getFullYear() }],
|
||||
queryKey: [
|
||||
'calendar/medias',
|
||||
{ month: month.getMonth(), year: month.getFullYear(), v4: widget.properties.useSonarrv4 },
|
||||
],
|
||||
staleTime: 1000 * 60 * 60 * 5,
|
||||
enabled: isEditMode === false,
|
||||
queryFn: async () =>
|
||||
(await (
|
||||
await fetch(
|
||||
|
||||
Reference in New Issue
Block a user