From 4377415e35c0914bfa79c406fd5759c09c1af411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 12 Aug 2020 16:57:54 +0200 Subject: Improve filtering when loading vcomponents. --- module/vcomponent/instance/methods.scm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/module/vcomponent/instance/methods.scm b/module/vcomponent/instance/methods.scm index 4baf9409..ea3522f9 100644 --- a/module/vcomponent/instance/methods.scm +++ b/module/vcomponent/instance/methods.scm @@ -54,13 +54,18 @@ (slot-set! this 'calendars (load-calendars (slot-ref this 'calendar-files))) - (slot-set! this 'events - (concatenate - (map (lambda (cal) (remove - (extract 'X-HNH-REMOVED) - (filter (lambda (o) (eq? 'VEVENT (type o))) - (children cal)))) - (slot-ref this 'calendars)))) + + (let* ((groups + (group-by + type (concatenate + (map children (slot-ref this 'calendars))))) + (events (awhen (assoc-ref groups 'VEVENT) + (car it))) + (removed remaining (partition (extract 'X-HNH-REMOVED) events))) + + ;; TODO figure out what to do with removed events + + (slot-set! this 'events (append #|removed|# remaining))) (let* ((repeating regular (partition repeating? (slot-ref this 'events)))) (slot-set! this 'fixed-events (sort*! regular date/-time