Open Bug 389156 Opened 19 years ago Updated 2 years ago

Deleting a Calendar doesn't remove the entry from open event dialogs

Categories

(Calendar :: Dialogs, defect)

defect

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: Fallen, Assigned: thelizardreborn, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [lang=js])

Attachments

(2 files, 1 external file)

Steps: * Open the event dialog to create a new event * Delete a Calendar Results: * The deleted calendar is still in the dropdown list * No Error in the error console Expected: * The deleted calendar is not in the dropdown
Component: Calendar Views → Dialogs
QA Contact: views → dialogs
Whiteboard: [good first bug][mentor=Fallen][lang=js]
sir i want to solve this bug.solving this would be a great opportunity for me.it would be great if this is assigned to me.
Assignee: nobody → bk.spartann
Status: NEW → ASSIGNED
Bablu, can you confirm that you're still working on this?
Flags: needinfo?(bk.spartann)
hii assign this bug to someone else as i'm not able to devote enough time to this bug.
Flags: needinfo?(bk.spartann)
Assignee: bk.spartann → nobody
Status: ASSIGNED → NEW
The attached patch adds an observer in calendar-event-dialog.js@loadDialog and removes (or adds, although the bugreport didn't state this) the relevant calendars on the fly. If the currently selected calendar is removed, the menu index is set to -1 which should (imho) force the user to select a calendar. Sadly this isn't the case, seems there is some kind of validation missing. Apart from that, I might have gone a little out of scope by messing with the appenCalendarItems function in calendar-ui-utils.js. Basicly I added functions to add and remove single calendar items and made sure the existing "plural" functions uses the new "singular" function. And besides that, I didn't find a way to search inside list items using a predicate or similar. So I wrote a boilerplate loop (see removeCalendarItem) ... If there is a better way to do this I would love to know it.
Attachment #8351632 - Flags: review?(philipp)
Assignee: nobody → Marcus
Status: NEW → ASSIGNED
Comment on attachment 8351632 [details] [diff] [review] Added calendar listener to add and remove calendars on the fly Review of attachment 8351632 [details] [diff] [review]: ----------------------------------------------------------------- Almost perfect, thanks for the patch! r- for now to handle below comments and anything we discussed in person. Keep up the good work! ::: calendar/base/content/calendar-ui-utils.js @@ +315,5 @@ > + menuItemIndex = aCalendarMenuParent.itemCount; > + let menuItem = addMenuItem(aCalendarMenuParent, calendar.name, calendar.name); > + > + menuItem.calendar = calendar; > + if (aOnCommand) { minor nit: There is a line with trailing whitespaces around here, please check. Also in two other places @@ +338,5 @@ > + * menupopup or a menulist > + */ > +function removeCalendarItem(aCalendar, aCalendarMenuParent) { > + let findCalendarMenuItemIndex = function() { > + for (var i = 0; i < aCalendarMenuParent.itemCount; ++i) { let instead of var @@ +346,5 @@ > + return (i); > + } > + } > + > + return (-1); No need for () around the number and the i above. ::: calendar/base/content/dialogs/calendar-event-dialog.js @@ +345,5 @@ > > + // Keep track whether the available calendars have changed for some reason. > + // As the dialog is non-modal, users may add or remove calendars any time > + // and the calendar list should reflect this. > + getCalendarManager().addObserver({ Please use cal.getCalendarManager() and make sure the observer is removed again when the dialog is closed. @@ +354,5 @@ > + onCalendarRegistered : function(calendar) { > + appendCalendarItem(calendar, calendarList); > + }, > + > + onCalendarDeleting : function(calendar) { As discussed, it would be nice to handle the case when a calendar is deleted. Bonus points for using the notification box.
Attachment #8351632 - Flags: review?(philipp) → review-
Mentor: philipp
Whiteboard: [good first bug][mentor=Fallen][lang=js] → [good first bug][lang=js]
Keywords: good-first-bug
Whiteboard: [good first bug][lang=js] → [lang=js]
Assignee: bugs → nobody
Status: ASSIGNED → NEW

I am an outreachy applicant. Can I take this bug? Thank you :)

Severity: normal → S3

Philipp, can we close this bug? Is this still relevant?

Flags: needinfo?(philipp)

No, this is still an issue in Thunderbird 119

Flags: needinfo?(philipp)

I'm going to take a crack at reviving the original patch on this with the suggested changes. I realize it's been 10 years since it was originally submitted, so I'll do my best to track the correct places for the changes, and make relevant updates to the patch (const, etc).

Only question I've got is what was meant by "Bonus points for using the notification box" regarding the calendar deletion case.

Flags: needinfo?(philipp)

This appears to be working. There have been some changes to the calendar manager and observers that needed worked out, but have been accounted for. I also tried to address the requests made by Philipp on the original patch.

Attachment #9397497 - Flags: review?(philipp)
Comment on attachment 9397497 [details] [diff] [review] Update calendar dropdown when available cals change Review of attachment 9397497 [details] [diff] [review]: ----------------------------------------------------------------- Can you submit the patch using moz-phab? https://developer.thunderbird.net/thunderbird-development/fixing-a-bug#submitting-a-patch We don't use raw patches anymore. ::: calendar/base/content/calendar-ui-utils.js @@ +165,5 @@ > +* item wasn't added. > +*/ > +function appendCalendarItem(aCalendar, aCalendarMenuParent, aOnCommand) { > + let menuItemIndex = -1; > + if (aCalendar) { I think passing null should not be allowed. We're trying to improve the jsdocs (this file is not touched up yet). But since you're adding new code, it should be like ``` @param {calICalendar} aCalendar - The calendar. @param {Node} aCalendarMenuParent - The direct parent of the menuitems - either a menupopup or a menulist. @param {?string} aOnCommand - String to set the oncommand attribute to. @returns {integer} the index the calendar was added at. ``` ::: calendar/base/content/item-editing/calendar-item-iframe.js @@ +623,5 @@ > + removeCalendarItem(calendar, calendarList); > + } > + }; > + > + cal.manager.addObserver(calendarObserver); Should also be a call to .manager.removeObserver somewhere (on unload?)
Attachment #9397497 - Flags: review?(philipp)

Who should I add as reviewer?

You can put r=#thunderbird-reviewers

Assignee: nobody → thelizardreborn
Status: NEW → ASSIGNED

I figured out the notification box, so I don't need that answered anymore (for future reference, the event dialog notification box is currently used via the notifyUser function in calendar-item-iframe.js)

Flags: needinfo?(philipp)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: