Bug 1335447 - Event Dialog: error "rule.untilDate is null" when changing recurrence rule from a "custom" rule. r=MakeMyDay a=philipp
authorDecathlon <bv1578@gmail.com>
Sat, 04 Feb 2017 23:32:20 +0100
changeset 27744 bdb83c35964e602cbf5f604e2fc3ed3d93ffda1c
parent 20688 7ee416445f296f50e82c220ba667574fcb421ebd
child 27745 57554453cc0a9fed84356632e050666827739a90
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay, philipp
bugs1335447
Bug 1335447 - Event Dialog: error "rule.untilDate is null" when changing recurrence rule from a "custom" rule. r=MakeMyDay a=philipp
calendar/lightning/content/lightning-item-iframe.js
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -2673,32 +2673,37 @@ function updateRepeat(aSuppressDialogs, 
             recurrenceInfo = recurrenceInfo.clone();
             let rrules = splitRecurrenceRules(recurrenceInfo);
             let rule = rrules[0][0];
 
             // If the previous rule was "custom" we have to recover the until
             // date, or the last occurrence's date in order to set the
             // repeat-until-datepicker with the same date.
             if (aItemRepeatCall && repeatDeck.selectedIndex == 1) {
+                let repeatDate;
                 if (!rule.isByCount || !rule.isFinite) {
-                    setElementValue("repeat-until-datepicker",
-                                    rule.isByCount ? "forever"
-                                                   : cal.dateTimeToJsDate(rule.untilDate.getInTimezone(cal.floating())));
+                    if (rule.isFinite) {
+                        repeatDate = rule.untilDate.getInTimezone(cal.floating());
+                        repeatDate = cal.dateTimeToJsDate(repeatDate);
+                    } else {
+                        repeatDate = "forever";
+                    }
                 } else {
                     // Try to recover the last occurrence in 10(?) years.
                     let endDate = gStartTime.clone();
                     endDate.year += 10;
                     let lastOccurrenceDate = null;
                     let dates = recurrenceInfo.getOccurrenceDates(gStartTime, endDate, 0, {});
                     if (dates) {
                         lastOccurrenceDate = dates[dates.length - 1];
                     }
-                    let repeatDate = cal.dateTimeToJsDate((lastOccurrenceDate || proposedUntilDate).getInTimezone(cal.floating()));
-                    setElementValue("repeat-until-datepicker", repeatDate);
+                    repeatDate = (lastOccurrenceDate || proposedUntilDate).getInTimezone(cal.floating());
+                    repeatDate = cal.dateTimeToJsDate(repeatDate);
                 }
+                setElementValue("repeat-until-datepicker", repeatDate);
             }
             if (rrules[0].length > 0) {
                 recurrenceInfo.deleteRecurrenceItem(rule);
             }
         } else {
             // New event proposes "forever" as default until date.
             recurrenceInfo = createRecurrenceInfo(item);
             setElementValue("repeat-until-datepicker", "forever");