mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 06:55:51 +01:00
♻️ Deprecate calendar firstdayofweek option
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
"useSonarrv4": {
|
||||
"label": "Use Sonarr v4 API"
|
||||
},
|
||||
"sundayStart": {
|
||||
"label": "Start the week on Sunday"
|
||||
},
|
||||
"radarrReleaseType": {
|
||||
"label": "Radarr release type"
|
||||
},
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { ColorScheme as MantineColorScheme, MantineProvider, MantineTheme } from '@mantine/core';
|
||||
import { ModalsProvider } from '@mantine/modals';
|
||||
import { Notifications } from '@mantine/notifications';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
|
||||
import Consola from 'consola';
|
||||
import { getCookie, setCookie } from 'cookies-next';
|
||||
import 'flag-icons/css/flag-icons.min.css';
|
||||
@@ -13,15 +10,12 @@ import { Session } from 'next-auth';
|
||||
import { SessionProvider, getSession } from 'next-auth/react';
|
||||
import { appWithTranslation } from 'next-i18next';
|
||||
import { AppProps } from 'next/app';
|
||||
import Head from 'next/head';
|
||||
import { useEffect, useState } from 'react';
|
||||
import 'video.js/dist/video-js.css';
|
||||
import { z } from 'zod';
|
||||
import { CommonHead } from '~/components/layout/Meta/CommonHead';
|
||||
import { env } from '~/env.js';
|
||||
import { ColorSchemeProvider } from '~/hooks/use-colorscheme';
|
||||
import { modals } from '~/modals';
|
||||
import { queryClient } from '~/tools/server/configurations/tanstack/queryClient.tool';
|
||||
import { ConfigType } from '~/types/config';
|
||||
import { api } from '~/utils/api';
|
||||
import { colorSchemeParser } from '~/validations/user';
|
||||
@@ -71,10 +65,6 @@ function App(
|
||||
|
||||
const { setInitialPackageAttributes } = usePackageAttributesStore();
|
||||
|
||||
const asyncStoragePersister = createAsyncStoragePersister({
|
||||
storage: AsyncStorage,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setInitialPackageAttributes(props.pageProps.packageAttributes);
|
||||
}, []);
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* We also create a few inference helpers for input and output types.
|
||||
*/
|
||||
import { createTRPCProxyClient, httpBatchLink, loggerLink } from '@trpc/client';
|
||||
import { createTRPCNext } from '@trpc/next';
|
||||
import { WithTRPCConfig, createTRPCNext } from '@trpc/next';
|
||||
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server';
|
||||
import superjson from 'superjson';
|
||||
import { env } from '~/env';
|
||||
import { type RootRouter } from '~/server/api/root';
|
||||
import { queryClient } from '~/tools/server/configurations/tanstack/queryClient.tool';
|
||||
|
||||
const getTrpcConfiguration = () => ({
|
||||
/**
|
||||
@@ -34,6 +35,7 @@ const getTrpcConfiguration = () => ({
|
||||
url: `${getBaseUrl()}/api/trpc`,
|
||||
}),
|
||||
],
|
||||
queryClient,
|
||||
});
|
||||
|
||||
const getBaseUrl = () => {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useMantineTheme } from '@mantine/core';
|
||||
import { Calendar } from '@mantine/dates';
|
||||
import { IconCalendarTime } from '@tabler/icons-react';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { i18n } from 'next-i18next';
|
||||
import { useState } from 'react';
|
||||
import { api } from '~/utils/api';
|
||||
import { RouterOutputs, api } from '~/utils/api';
|
||||
|
||||
import { useEditModeStore } from '../../components/Dashboard/Views/useEditModeStore';
|
||||
import { useConfigContext } from '../../config/provider';
|
||||
@@ -25,10 +26,6 @@ const definition = defineWidget({
|
||||
type: 'switch',
|
||||
defaultValue: false,
|
||||
},
|
||||
sundayStart: {
|
||||
type: 'switch',
|
||||
defaultValue: false,
|
||||
},
|
||||
radarrReleaseType: {
|
||||
type: 'select',
|
||||
defaultValue: 'inCinemas',
|
||||
@@ -70,6 +67,10 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
||||
const { name: configName } = useConfigContext();
|
||||
const [month, setMonth] = useState(new Date());
|
||||
const isEditMode = useEditModeStore((x) => x.enabled);
|
||||
const { data: sessionData } = useSession();
|
||||
const { data: userWithSettings } = api.user.withSettings.useQuery(undefined, {
|
||||
enabled: !!sessionData?.user,
|
||||
});
|
||||
|
||||
const { data: medias } = api.calendar.medias.useQuery(
|
||||
{
|
||||
@@ -84,6 +85,8 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
||||
}
|
||||
);
|
||||
|
||||
const firstDayOfWeek = userWithSettings?.settings.firstDayOfWeek ?? 'monday';
|
||||
|
||||
return (
|
||||
<Calendar
|
||||
defaultDate={new Date()}
|
||||
@@ -91,7 +94,7 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
||||
onNextMonth={setMonth}
|
||||
size={widget.properties.fontSize}
|
||||
locale={i18n?.resolvedLanguage ?? 'en'}
|
||||
firstDayOfWeek={widget.properties.sundayStart ? 0 : 1}
|
||||
firstDayOfWeek={getFirstDayOfWeek(firstDayOfWeek)}
|
||||
hideWeekdays={widget.properties.hideWeekDays}
|
||||
style={{ position: 'relative' }}
|
||||
date={month}
|
||||
@@ -147,6 +150,13 @@ function CalendarTile({ widget }: CalendarTileProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const getFirstDayOfWeek = (
|
||||
firstDayOfWeek: RouterOutputs['user']['withSettings']['settings']['firstDayOfWeek']
|
||||
) => {
|
||||
if (firstDayOfWeek === 'sunday') return 0;
|
||||
if (firstDayOfWeek === 'monday') return 1;
|
||||
return 6;
|
||||
};
|
||||
const getReleasedMediasForDate = (
|
||||
medias: MediasType | undefined,
|
||||
date: Date,
|
||||
|
||||
Reference in New Issue
Block a user