@@ -208,6 +208,7 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config:
208208export function processEvents ( allEvents : any [ ] , config : atomicCardConfig ) {
209209 let newEvents = allEvents . reduce ( ( events , calEvent ) => {
210210 calEvent . originCalendar = config . entities . find ( entity => entity . entity === calEvent . entity . entity ) ;
211+ console . log ( events ) ;
211212
212213 const newEvent : EventClass = new EventClass ( calEvent , config ) ;
213214
@@ -251,28 +252,15 @@ export function processEvents(allEvents: any[], config: atomicCardConfig) {
251252 events . push ( newEvent ) ;
252253 }
253254
254- // Check if the hideFinishedEvents is set, if it is, remove any events
255- // that are already finished
256- if ( config . hideFinishedEvents ) {
257- events = events . filter ( function ( e : EventClass ) { return e . isFinished == false } )
258- }
259-
260- // check if the maxEventCount is set, if it is we will remove any events
261- // that go over this limit, unless softLimit is set, in which case we
262- // will remove any events over the soft limit
263- if ( config . maxEventCount ) {
264- if ( ( ! config . softLimit && config . maxEventCount < events . length ) ||
265- ( config . softLimit && events . length > config . maxEventCount + config . softLimit )
266- ) {
267- //TODO: hidden events?
268- events . length = config . maxEventCount
269- }
270-
271- }
272-
273255 return events ;
274256 } , [ ] ) ;
275257
258+ // Check if the hideFinishedEvents is set, if it is, remove any events
259+ // that are already finished
260+ if ( config . hideFinishedEvents ) {
261+ newEvents = newEvents . filter ( function ( e : EventClass ) { return e . isFinished == false } )
262+ }
263+
276264 // if hideDuplicates remove any duplicate events where
277265 // title, startDateTime and endDateTime match
278266 if ( config . hideDuplicates ) {
@@ -287,5 +275,18 @@ export function processEvents(allEvents: any[], config: atomicCardConfig) {
287275 newEvents . sort ( ( a : EventClass , b : EventClass ) => a . startDateTime . isBefore ( b . startDateTime ) ? - 1 : 1 ) ;
288276 }
289277
278+ // check if the maxEventCount is set, if it is we will remove any events
279+ // that go over this limit, unless softLimit is set, in which case we
280+ // will remove any events over the soft limit
281+ if ( config . maxEventCount ) {
282+ if ( ( ! config . softLimit && config . maxEventCount < newEvents . length ) ||
283+ ( config . softLimit && newEvents . length > config . maxEventCount + config . softLimit )
284+ ) {
285+ //TODO: hidden events?
286+ newEvents . length = config . maxEventCount
287+ }
288+
289+ }
290+
290291 return newEvents ;
291292}
0 commit comments