Closed Bug 435763 Opened 16 years ago Closed 16 years ago

Implement calIItemBase::previousOccurrence/nextOccurrence

Categories

(Calendar :: Internal Components, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 391495

People

(Reporter: Fallen, Assigned: Fallen)

Details

Attachments

(4 obsolete files)

Attached patch Fix - v1 (obsolete) (deleted) β€” β€” Splinter Review
Makes life easier for bug 320178 and makes the review bits smaller.
Attachment #322522 - Flags: review?(daniel.boelzle)
Comment on attachment 322522 [details] [diff] [review] Fix - v1 I don't spot any IDL for that, so how it's accessed? Making the methods part of calIItemBase looks wrong to me, because those can only be called on occurrences: Both parent items (of recurring items) and non-recurring items will return null. Why don't you offer calIRecurrenceInfo::getPreviousOccurrence(recurrenceId) instead or some free helper functions?
Attachment #322522 - Flags: review?(daniel.boelzle) → review-
(In reply to comment #1) > (From update of attachment 322522 [details] [diff] [review]) > I don't spot any IDL for that, so how it's accessed? http://mxr.mozilla.org/mozilla1.8/source/calendar/base/public/calIItemBase.idl#285 > Making the methods part of calIItemBase looks wrong to me, because those can > only be called on occurrences: Both parent items (of recurring items) and > non-recurring items will return null. > > Why don't you offer calIRecurrenceInfo::getPreviousOccurrence(recurrenceId) > instead or some free helper functions? I could live with that. Making it part of calItemBase was probably done as a shortcut.
Attached patch Alternative fix - v2 (obsolete) (deleted) β€” β€” Splinter Review
This would be the alternative. I kind of liked the ease of the previousOccurrence/nextOccurrence attributes. This way when on an occurrence, you need to call occ.parentItem.recurrenceInfo.getPreviousOccurrence(occ.recurrenceId); Please reconsider, but r+ which ever you like :-)
Attachment #323101 - Flags: review?(daniel.boelzle)
Comment on attachment 323101 [details] [diff] [review] Alternative fix - v2 I like this approach better, completing calIRecurrenceInfo. The API looks good. >+ getPreviousOccurrence: function cRI_getPreviousOccurrence(aDate) { >+ var recurrenceStartDate = this.mBaseItem.recurrenceStartDate; >+ if (aDate && recurrenceStartDate && aDate.compare(recurrenceStartDate) != 0) { >+ // The above conditions are optimized, so that if this is the first >+ // occurrence, null is returned directly. >+ >+ // TODO libical currently does not provide us with easy means of >+ // getting the previous occurrence. This could be fixed to improve >+ // performance greatly. Filed as libical feature request 1944020. >+ var occs = this.getOccurrenceDates(recurrenceStartDate, >+ aDate, >+ null, >+ {}); You must not use getOccurrenceDates here, because that will give you DTSTART dates not RECURRENCE-IDs that you need to feed getOccurrenceFor(). DTSTART may not match RECURRENCE-ID on exceptional/overridden items. Use calculateDates(..., true /* aReturnRIDs */); >+ return this.getOccurrenceFor(occs[occs.length - 1]); This gets the series from recurrenceStart. IMO you need to consider exceptional/overridden items which may occur before that.
Attachment #323101 - Flags: review?(daniel.boelzle) → review-
Attached patch Fix - v3 (obsolete) (deleted) β€” β€” Splinter Review
This should do it: calculateDates takes exceptions into account. I tested using a debug breakpoint and it seems to work fine for exdates and exceptions.
Attachment #322522 - Attachment is obsolete: true
Attachment #323101 - Attachment is obsolete: true
Attachment #323392 - Flags: review?(daniel.boelzle)
Comment on attachment 323392 [details] [diff] [review] Fix - v3 seems I cannot make my point cl >+ if (aDate && recurrenceStartDate && aDate.compare(recurrenceStartDate) != 0) { recurrenceStartDate need not be the first occurrence of the series w.r.t overridden items. >+ var rids = this.calculateDates(recurrenceStartDate, aDate, 0, true); same applies here: If you pass recurrenceStartDate as lower boundary, you miss overridden items that occur before recurrenceStartDate (i.e. have a DTSTART before that).
Attached patch Fix - v4 (obsolete) (deleted) β€” β€” Splinter Review
Attachment #323392 - Attachment is obsolete: true
Attachment #323536 - Flags: review?(daniel.boelzle)
Attachment #323392 - Flags: review?(daniel.boelzle)
Comment on attachment 323536 [details] [diff] [review] Fix - v4 No review as discussed, Philipp will come up with a revised API and more fixes of getNextOccurrence et al.
Attachment #323536 - Attachment is obsolete: true
Attachment #323536 - Flags: review?(daniel.boelzle)
Will be fixed in bug 391495.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
No longer blocks: 320178
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: