-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update sources in calendar chooser when source connects #742
base: master
Are you sure you want to change the base?
Update sources in calendar chooser when source connects #742
Conversation
If calendar chooser is displayed before sources are fully loaded, re-renders sources so that all calendars become available.
@@ -163,7 +163,7 @@ public class Maya.View.EventEdition.InfoPanel : Gtk.Grid { | |||
// Row: title & calendar | |||
attach (title_label, 0, 0, 1, 1); | |||
attach (title_entry, 0, 1, 1, 1); | |||
if (calendar_button.sources.length () > 1 && parent_dialog.can_edit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered adding this element only once all sources were initialized but given that the registry is accessed within the CalendarChooser component, it would have led to a lot of extra code. The only downside to this approach is that a user who only has one calendar will only have one source to select from in the dropdown. I think this is a reasonably minor UX tradeoff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a fine tradeoff. From my perspective (not on the UX team) having the selector present even with only one source may be good for consistency.
My only concern is that this could lead to a state where not all the sources are available in the chooser. Depending how long that state lasts it may be worthwhile to add a spinner or something of the sort, if there's an easy way to access a state that indicates we're still loading sources. This may not be much of an issue though.
calmodel.connected.connect (() => render_sources ()); | ||
} | ||
|
||
private void render_sources () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted render code into a private method so it can be used both in the initial constructor and as an event handler.
Worth noting that this will also fix an issue where no calendars appear if you open an ICS file from import with Calendar not already open. |
Sorry my review is taking a while. I'm working my way through the code. I'm encountering a crash when I open an ICS file on a cold start (the app and daemon are not running) that is not present in master. To see this crash, run
|
I believe I've tracked down the issue, and I don't think it's your fault, so I won't consider it a blocker for this PR. It looks like you uncovered a race condition. It appears that on constructing a |
May I ask how you're testing this? Thanks to the crash I mentioned above I can't figure out how to get to a state where the sources aren't already loaded before the My one concern is that this could lead to a hitch if a lot of calendars are added quickly, leading to many refreshes of the list. This may be outside the scope of this PR, but it seems like it should be possible to add the sources one at a time to the |
If calendar chooser is displayed before sources are fully loaded, re-renders sources so that all calendars become available.
This PR blocks elementary/wingpanel-indicator-datetime#299 as without it the added functionality is largely useless. The implementation of the linked PR relies on the existing method of launching the calendar application with a flag (
--add-event
) that tells the application to open a new event dialog. However, as currently implemented the new event dialog is loaded prior to all event sources having been initialized, so it is impossible to choose a destination calendar for the new event.This PR addresses this issue by 1) displaying the calendar selection regardless of the number of calendar sources the user has and 2) re-rendering the calendar options when sources are updated.
While a DBus implementation for adding new events from wingpanel would be a better option (and one I will explore in future,) this change does at least make the aforementioned flag usable.