1 import type { Api } from '@proton/shared/lib/interfaces';
3 import type { CalendarAlarmCache } from './CacheInterface';
4 import getPaginatedAlarms from './getPaginatedAlarms';
6 const getCalendarsAlarmsCached = (api: Api, cache: CalendarAlarmCache, calendarIDs: string[], dateRange: Date[]) => {
7 const promises = calendarIDs.map((calendarID) => {
8 if (cache[calendarID] && cache[calendarID].promise) {
9 return cache[calendarID].promise;
11 if (cache[calendarID] && cache[calendarID].result) {
15 const promise = getPaginatedAlarms(api, calendarID, dateRange)
22 delete cache[calendarID];
31 return Promise.all(promises);
34 export default getCalendarsAlarmsCached;