[gnome-calendar/fix-shifting-events] manager: Fix bug where recurring events shift after being edited
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/fix-shifting-events] manager: Fix bug where recurring events shift after being edited
- Date: Tue, 11 Oct 2022 19:38:39 +0000 (UTC)
commit fed9e3a498acd346674b0a710af48739bbe1c3f0
Author: Ray Strode <rstrode redhat com>
Date: Tue Oct 11 15:33:36 2022 -0400
manager: Fix bug where recurring events shift after being edited
Right now if a user edits say event 3 in a set of 5 events, the
whole event set gets shifted over by 3. It's as if the middle
event is treated as the new first event.
This is because of a hack in the code to clear the recurrence
id of the event, to get at the "main event", and edit the whole
set. This hack still leaves the start time on the event, causing
the main event to use a middle event start time.
This commit queries for the main event from the middle event,
and sets the middle event start time to match the main event,
before doing an update.
Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/882
src/core/gcal-manager.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/core/gcal-manager.c b/src/core/gcal-manager.c
index c5c54d36..b3920c25 100644
--- a/src/core/gcal-manager.c
+++ b/src/core/gcal-manager.c
@@ -1056,10 +1056,44 @@ gcal_manager_update_event (GcalManager *self,
* HACK: In Evolution Calendar, a NULL 'rid' is usually associated
* with an E_CAL_OBJ_MOD_ALL modtype. Here, we are manually setting
* the rid to NULL when modifying a recurrent event with MOD_ALL
- * modtype.
+ * modtype. This gives us the associated main event. We also need
+ * to fudge the event date start and end times to match that event.
*/
if (mod == GCAL_RECURRENCE_MOD_ALL)
- e_cal_component_set_recurid (component, NULL);
+ {
+ GError *error = NULL;
+ ECalComponentId *component_id;
+ ICalComponent *icalcomponent;
+
+ component_id = e_cal_component_get_id (component);
+ if (e_cal_client_get_object_sync (gcal_calendar_get_client (calendar),
+ e_cal_component_id_get_uid (component_id),
+ NULL,
+ &icalcomponent,
+ NULL,
+ &error))
+ {
+ ECalComponent *ecomponent;
+ ecomponent = e_cal_component_new_from_icalcomponent (icalcomponent);
+
+ if (ecomponent)
+ {
+ GcalEvent *main_event;
+
+ main_event = gcal_event_new (calendar, ecomponent, &error);
+
+ gcal_event_set_date_start (event, gcal_event_get_date_start (main_event));
+ gcal_event_set_date_end (event, gcal_event_get_date_end (main_event));
+
+ g_object_unref (main_event);
+ g_object_unref (ecomponent);
+ }
+ }
+ e_cal_component_id_free (component_id);
+ g_object_unref (icalcomponent);
+
+ e_cal_component_set_recurid (component, NULL);
+ }
/*
* While we're updating the event, we don't want the component
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]