feat(calendar): add show-unmonitored option (#2547)
* feat(calendar): add show-unmonitored option * fix: typecheck issue
This commit is contained in:
@@ -9,7 +9,14 @@ import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|||||||
|
|
||||||
export const calendarRouter = createTRPCRouter({
|
export const calendarRouter = createTRPCRouter({
|
||||||
findAllEvents: publicProcedure
|
findAllEvents: publicProcedure
|
||||||
.input(z.object({ year: z.number(), month: z.number(), releaseType: z.array(z.enum(radarrReleaseTypes)) }))
|
.input(
|
||||||
|
z.object({
|
||||||
|
year: z.number(),
|
||||||
|
month: z.number(),
|
||||||
|
releaseType: z.array(z.enum(radarrReleaseTypes)),
|
||||||
|
showUnmonitored: z.boolean(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
.unstable_concat(createManyIntegrationMiddleware("query", ...getIntegrationKindsByCategory("calendar")))
|
.unstable_concat(createManyIntegrationMiddleware("query", ...getIntegrationKindsByCategory("calendar")))
|
||||||
.query(async ({ ctx, input }) => {
|
.query(async ({ ctx, input }) => {
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const mediaOrganizerJob = createCronJob("mediaOrganizer", EVERY_MINUTE).w
|
|||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
releaseType: options.releaseType,
|
releaseType: options.releaseType,
|
||||||
|
showUnmonitored: options.showUnmonitored,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const optionMapping: OptionMapping = {
|
|||||||
releaseType: (oldOptions) => [oldOptions.radarrReleaseType],
|
releaseType: (oldOptions) => [oldOptions.radarrReleaseType],
|
||||||
filterFutureMonths: () => undefined,
|
filterFutureMonths: () => undefined,
|
||||||
filterPastMonths: () => undefined,
|
filterPastMonths: () => undefined,
|
||||||
|
showUnmonitored: ({ showUnmonitored }) => showUnmonitored,
|
||||||
},
|
},
|
||||||
clock: {
|
clock: {
|
||||||
customTitle: (oldOptions) => oldOptions.customTitle,
|
customTitle: (oldOptions) => oldOptions.customTitle,
|
||||||
|
|||||||
@@ -9,13 +9,17 @@ import { createCachedIntegrationRequestHandler } from "./lib/cached-integration-
|
|||||||
export const calendarMonthRequestHandler = createCachedIntegrationRequestHandler<
|
export const calendarMonthRequestHandler = createCachedIntegrationRequestHandler<
|
||||||
CalendarEvent[],
|
CalendarEvent[],
|
||||||
IntegrationKindByCategory<"calendar">,
|
IntegrationKindByCategory<"calendar">,
|
||||||
{ year: number; month: number; releaseType: RadarrReleaseType[] }
|
{ year: number; month: number; releaseType: RadarrReleaseType[]; showUnmonitored: boolean }
|
||||||
>({
|
>({
|
||||||
async requestAsync(integration, input) {
|
async requestAsync(integration, input) {
|
||||||
const integrationInstance = await createIntegrationAsync(integration);
|
const integrationInstance = await createIntegrationAsync(integration);
|
||||||
const startDate = dayjs().year(input.year).month(input.month).startOf("month");
|
const startDate = dayjs().year(input.year).month(input.month).startOf("month");
|
||||||
const endDate = startDate.clone().endOf("month");
|
const endDate = startDate.clone().endOf("month");
|
||||||
return await integrationInstance.getCalendarEventsAsync(startDate.toDate(), endDate.toDate());
|
return await integrationInstance.getCalendarEventsAsync(
|
||||||
|
startDate.toDate(),
|
||||||
|
endDate.toDate(),
|
||||||
|
input.showUnmonitored,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
cacheDuration: dayjs.duration(1, "minute"),
|
cacheDuration: dayjs.duration(1, "minute"),
|
||||||
queryKey: "calendarMonth",
|
queryKey: "calendarMonth",
|
||||||
|
|||||||
@@ -1434,6 +1434,9 @@
|
|||||||
},
|
},
|
||||||
"filterFutureMonths": {
|
"filterFutureMonths": {
|
||||||
"label": "End at"
|
"label": "End at"
|
||||||
|
},
|
||||||
|
"showUnmonitored": {
|
||||||
|
"label": "Show unmonitored"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const FetchCalendar = ({ month, setMonth, isEditMode, integrationIds, options }:
|
|||||||
month: month.getMonth(),
|
month: month.getMonth(),
|
||||||
year: month.getFullYear(),
|
year: month.getFullYear(),
|
||||||
releaseType: options.releaseType,
|
releaseType: options.releaseType,
|
||||||
|
showUnmonitored: options.showUnmonitored,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ export const { definition, componentLoader } = createWidgetDefinition("calendar"
|
|||||||
validate: z.number().min(2).max(9999),
|
validate: z.number().min(2).max(9999),
|
||||||
defaultValue: 2,
|
defaultValue: 2,
|
||||||
}),
|
}),
|
||||||
|
showUnmonitored: factory.switch({
|
||||||
|
defaultValue: false,
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
supportedIntegrations: getIntegrationKindsByCategory("calendar"),
|
supportedIntegrations: getIntegrationKindsByCategory("calendar"),
|
||||||
|
|||||||
Reference in New Issue
Block a user