timeline: Handle multiday events in calculate_changed_events

This patch do not sends ADD_EVENT for events that are multiday and are
part of the old_range when calling calculate_changed_events. This will
prevent multiday duplicate events to appear in the agenda widget when
using the week view.

If the event is a multiday and it was in the previous range, it won't
send the REMOVE_EVENT so multiday events won't dissapear when it's still
relevant.

See https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/898#note_1602391
This commit is contained in:
Daniel Garcia Moreno
2024-07-09 19:59:42 +00:00
committed by Georges Basile Stavracas Neto
parent d7bbda4eaa
commit c7875f03ff
3 changed files with 27 additions and 0 deletions
+18
View File
@@ -1929,3 +1929,21 @@ gcal_event_format_date (GcalEvent *self)
return g_steal_pointer (&formatted_string);
}
/**
* gcal_event_overlaps:
* @self: a #GcalEvent
* @range: a #GcalRange
*
* Returns: True if the event range overlaps the @range
*/
gboolean
gcal_event_overlaps (GcalEvent *self,
GcalRange *range)
{
GcalRangeOverlap overlap;
g_return_val_if_fail (GCAL_IS_EVENT (self), FALSE);
overlap = gcal_range_calculate_overlap (gcal_event_get_range (self), range, NULL);
return overlap != GCAL_RANGE_NO_OVERLAP;
}
+3
View File
@@ -136,6 +136,9 @@ void gcal_event_get_original_timezones (GcalEvent
gchar* gcal_event_format_date (GcalEvent *self);
gboolean gcal_event_overlaps (GcalEvent *self,
GcalRange *range);
G_END_DECLS
#endif /* GCAL_EVENT_H */
+6
View File
@@ -411,6 +411,9 @@ calculate_changed_events (GcalTimeline *self,
for (i = 0; events_to_remove && i < events_to_remove->len; i++)
{
GcalEvent *event = g_ptr_array_index (events_to_remove, i);
/* Do not re-remove multiday events that are part of new range */
if (gcal_event_is_multiday (event) && gcal_event_overlaps (event, new_range))
continue;
GCAL_TRACE_MSG ("Removing event from subscriber %s due to time range change (event: '%s' (%s))",
G_OBJECT_TYPE_NAME (subscriber),
@@ -423,6 +426,9 @@ calculate_changed_events (GcalTimeline *self,
for (i = 0; events_to_add && i < events_to_add->len; i++)
{
GcalEvent *event = g_ptr_array_index (events_to_add, i);
/* Do not re-add multiday events that were part of old range */
if (gcal_event_is_multiday (event) && gcal_event_overlaps (event, old_range))
continue;
GCAL_TRACE_MSG ("Queueing event addition for subscriber %s (event: '%s' (%s))",
G_OBJECT_TYPE_NAME (subscriber),