Blob Blame History Raw
From 78a6a28a7bf4d8ecac3863eb20d9f4aa9074a068 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 11 Oct 2022 13:35:31 -0400
Subject: [PATCH] manager: Refresh timeline when events are updated

gnome-calendar isn't exactly processing the stream of event
changes from eds properly. eds only notifies about changes in
the main event when, when there are related changes in other
recurrent events in the batch.

Rather than sort that out, for now, just do a full timeline refresh
any time there's a change in an event.

Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/881
---
 src/core/gcal-manager.c  |  6 ++++++
 src/core/gcal-timeline.c | 10 ++++++++++
 src/core/gcal-timeline.h |  1 +
 3 files changed, 17 insertions(+)

diff --git a/src/core/gcal-manager.c b/src/core/gcal-manager.c
index c5c54d36..f41de481 100644
--- a/src/core/gcal-manager.c
+++ b/src/core/gcal-manager.c
@@ -381,10 +381,13 @@ on_event_updated (GObject      *source_object,
                   GAsyncResult *result,
                   gpointer      user_data)
 {
+  GcalManager *self;
   GError *error = NULL;
 
   GCAL_ENTRY;
 
+  self = GCAL_MANAGER (g_object_get_data (user_data, "GcalManager"));
+
   if (! e_cal_client_modify_object_finish (E_CAL_CLIENT (source_object),
                                            result,
                                            &error))
@@ -394,6 +397,8 @@ on_event_updated (GObject      *source_object,
     }
   g_object_unref (E_CAL_COMPONENT (user_data));
 
+  gcal_timeline_refresh (self->timeline);
+
   GCAL_EXIT;
 }
 
@@ -1068,6 +1073,7 @@ gcal_manager_update_event (GcalManager           *self,
    */
   g_object_ref (component);
 
+  g_object_set_data (G_OBJECT (component), "GcalManager", GCAL_MANAGER (self));
   e_cal_client_modify_object (gcal_calendar_get_client (calendar),
                               e_cal_component_get_icalcomponent (component),
                               (ECalObjModType) mod,
diff --git a/src/core/gcal-timeline.c b/src/core/gcal-timeline.c
index dcec4cb3..c3853333 100644
--- a/src/core/gcal-timeline.c
+++ b/src/core/gcal-timeline.c
@@ -1076,3 +1076,13 @@ gcal_timeline_is_complete (GcalTimeline *self)
 
   return is_timeline_complete (self);
 }
+
+void
+gcal_timeline_refresh (GcalTimeline *self)
+{
+  GCAL_ENTRY;
+
+  update_calendar_monitor_filters (self);
+
+  GCAL_EXIT;
+}
diff --git a/src/core/gcal-timeline.h b/src/core/gcal-timeline.h
index 6d088330..c2c43714 100644
--- a/src/core/gcal-timeline.h
+++ b/src/core/gcal-timeline.h
@@ -53,5 +53,6 @@ void                 gcal_timeline_set_filter                    (GcalTimeline
                                                                   const gchar        *filter);
 
 gboolean             gcal_timeline_is_complete                   (GcalTimeline       *self);
+void                 gcal_timeline_refresh                       (GcalTimeline       *self);
 
 G_END_DECLS
-- 
GitLab