Avoid duplication when adding online calendars

When subscribing to one or multiple online Webcal or CalDAV calendars,
do not unexpectedly create an extra local calendar.

While this doesn't allow customizing names & colors while subscribing,
users can still easily set those just after adding the subscriptions,
as they are then returned to the "Calendars" page of "Manage Calendars".

Punting this to a separate step might not seem like the "perfect" flow,
but it works well enough and fixes the buggy UX that we currently had.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/566
Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/978
This commit is contained in:
Jean-François Fortin Tam
2024-07-09 16:44:01 -04:00
parent 75a42c7d83
commit 006437bf61
@@ -147,10 +147,10 @@ update_add_button (GcalNewCalendarPage *self)
gtk_widget_set_sensitive (self->add_button, valid);
n_calendars = 0;
if (self->local_source)
n_calendars++;
if (self->remote_sources)
n_calendars += self->remote_sources->len;
else if (self->local_source)
n_calendars++;
if (n_calendars > 0)
{
@@ -391,10 +391,6 @@ on_add_button_clicked_cb (GtkWidget *button,
manager = gcal_context_get_manager (self->context);
/* Commit the new source */
if (self->local_source)
gcal_manager_save_source (manager, self->local_source);
/* Commit each new remote source */
if (self->remote_sources)
{
@@ -406,6 +402,11 @@ on_add_button_clicked_cb (GtkWidget *button,
g_clear_pointer (&self->remote_sources, g_ptr_array_unref);
}
else
{
gcal_manager_save_source (manager, self->local_source);
}
gcal_calendar_management_page_switch_page (GCAL_CALENDAR_MANAGEMENT_PAGE (self),
"calendars",
NULL);