Closed Bug 1621791 Opened 4 years ago Closed 4 years ago

Disable some calendar keyboard shortcuts when calendar is not used


(Calendar :: General, task)

Not set


(Not tracked)

Thunderbird 76.0


(Reporter: pmorris, Assigned: pmorris)




(3 files, 2 obsolete files)

+++ This bug was initially created as a clone of Bug #1621130 +++

Following up on bug 1617786, disable any keyboard shortcuts that should be disabled. Here's a relevant bit from the 5th comment on that bug.

"For keyboard shortcuts I found a couple <command>s to disable ("calendar_toggle_todaypane_command", "calendar_go_to_today_command"). Luckily the toggle_todaypane keyboard shortcut is already getting disabled without any extra effort required. The go_to_today one is not, but it's tricky because even if you disable it, when you open a calendar tab it gets re-enabled. (Disabling it is pretty low priority. If a user accidentally hits alt+end in a mail tab a calendar tab will open, which isn't so bad but not ideal.)"

I'd suggest wontfix for this.

At the very least, calendarUpdateNewItemsCommand needs to be called when a calendar is enabled or disabled (this probably should already happen, but doesn't) because if Thunderbird starts without an enabled calendar and one becomes enabled, the commands are still disabled. At a quick glance I'd say here is the right place.

This handles calling calendarUpdateNewItemsCommand when a calendar is enabled or disabled.

Attachment #9133346 - Flags: review?(geoff)

I noticed that the "Synchronize" toolbar button/command was not being disabled when all remote calendars were disabled. This patch basically fixes that, but a glitch remains.

When all remote calendars are disabled, and then you enable one, the command is updated immediately. Going the other way, when you disable the last one that is enabled, the update is not immediate but does eventually take effect, like when you switch away from the calendar tab and then back to it. I haven't had a chance to dig into how to fix that part yet.

Attachment #9133347 - Flags: review?(geoff)
Comment on attachment 9133346 [details] [diff] [review]

Review of attachment 9133346 [details] [diff] [review]:

::: calendar/base/content/calendar-command-controller.js
@@ +897,5 @@
>      "calendar_new_todo_context_command",
>      "calendar_new_todo_todaypane_command",
>    ];
> +  commandsToUpdate.forEach(goUpdateCommand);

Nice tidy-up. You could forget the variable and put the .forEach directly on the array.

::: calendar/base/content/calendar-management.js
@@ +624,5 @@
> +    // Update commands when a calendar is enabled or disabled.
> +    if (name == "disabled") {
> +      calendarUpdateNewItemsCommand();
> +    }
> +  },

This is a bit nit-picky, but I'd rather keep these methods in the order they're declared in calICalendar.idl. I'd accept either onPropertyChanged and onLoad put back with the others, or both here but with onPropertyChanged after onLoad. Your call.
Attachment #9133346 - Flags: review?(geoff) → review+
Comment on attachment 9133347 [details] [diff] [review]

Review of attachment 9133347 [details] [diff] [review]:

Surely the fix is to add calendar_reload_remote_calendars to the updated commands in the other patch.

::: calendar/base/content/calendar-command-controller.js
@@ +571,5 @@
>     * Returns a boolean indicating if all calendars are local
>     */
>    get no_network_calendars() {
>      return cal.getCalendarManager().networkCalendarCount == 0;
>    },

This is now unused and could be removed.
Attachment #9133347 - Flags: review?(geoff) → review+

Addresses review comments.

Attachment #9133346 - Attachment is obsolete: true
Attachment #9133707 - Flags: review+

Addresses review comments. It seemed worthwhile to update all the commands when a calendar was enabled or disabled, enabling/disabling is not a high frequency occurrence, and this approach will be more future-proof.

(I did discover the reason for the asymmetrical behavior I was seeing. When a network calendar is enabled the onLoad function is called (and commands are updated), but there's no corresponding call when disabling a networked calendar. Also onLoad is not called when a local calendar is enabled.)

Attachment #9133347 - Attachment is obsolete: true
Attachment #9133708 - Flags: review+

Some more tidying up while I was at it. Use a Set instead of an Object-used-like-a-set to store the command lists (now that JS has Sets).

Try runs (look fine):

Attachment #9133710 - Flags: review?(geoff)
Attachment #9133710 - Flags: review?(geoff) → review+

Pushed by
Update new item commands on calendar enable/disable. r=darktrojan
Improve disabling of synchronize calendars command. r=darktrojan
Store calendar commands in a Set not an Object. r=darktrojan DONTBUILD

Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 76
Type: enhancement → task
Regressions: 1658216
You need to log in before you can comment on or make changes to this bug.