Skip to content

Commit

Permalink
Backed out changeset 2b47a6bef4c7 - push to comm-central instead of t…
Browse files Browse the repository at this point in the history
…ry DONTBUILD
  • Loading branch information
Jorg K committed Jul 27, 2016
1 parent d20b86b commit 0ba6f65
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 67 deletions.
59 changes: 6 additions & 53 deletions calendar/base/content/dialogs/calendar-alarm-dialog.js
Expand Up @@ -27,11 +27,9 @@ function getAlarmService() {
*/
function onSnoozeAlarm(event) {
// reschedule alarm:
let duration = getDuration(event.detail);
if (aboveSnoozeLimit(duration)) {
// we prevent snoozing too far if the alarm wouldn't be displayed
return;
}
let duration = cal.createDuration();
duration.minutes = event.detail;
duration.normalize();
getAlarmService().snoozeAlarm(event.target.item, event.target.alarm, duration);
}

Expand Down Expand Up @@ -155,11 +153,9 @@ function updateRelativeDates() {
* @param aDurationMinutes The duration in minutes
*/
function snoozeAllItems(aDurationMinutes) {
let duration = getDuration(aDurationMinutes);
if (aboveSnoozeLimit(duration)) {
// we prevent snoozing too far if the alarm wouldn't be displayed
return;
}
let duration = cal.createDuration();
duration.minutes = aDurationMinutes;
duration.normalize();

let alarmRichlist = document.getElementById("alarm-richlist");
let parentItems = {};
Expand All @@ -176,49 +172,6 @@ function snoozeAllItems(aDurationMinutes) {
}
}

/**
* Receive a calIDuration object for a given number of minutes
*
* @param {long} aMinutes The number of minutes
* @return {calIDuration}
*/
function getDuration(aMinutes) {
const MINUTESINWEEK = 7 * 24 * 60;

// converting to weeks if any is required to avoid an integer overflow of duration.minutes as
// this is of type short
let weeks = Math.floor(aMinutes / MINUTESINWEEK);
aMinutes -= weeks * MINUTESINWEEK;

let duration = cal.createDuration();
duration.minutes = aMinutes;
duration.weeks = weeks;
duration.normalize();
return duration;
}

/**
* Check whether the snooze period exceeds the current limitation of the AlarmService and prompt
* the user with a message if so
* @param {calIDuration} aDuration The duration to snooze
* @returns {Boolean}
*/
function aboveSnoozeLimit(aDuration) {
const LIMIT = Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;

let currentTime = cal.now().getInTimezone(cal.UTC());
let limitTime = currentTime.clone();
limitTime.month += LIMIT;

let durationUntilLimit = limitTime.subtractDate(currentTime);
if (aDuration.compare(durationUntilLimit) > 0) {
let msg = PluralForm.get(LIMIT, cal.calGetString("calendar", "alarmSnoozeLimitExceeded"));
showError(msg.replace("#1", LIMIT));
return true;
}
return false;
}

/**
* Sets up the window title, counting the number of alarms in the window.
*/
Expand Down
6 changes: 0 additions & 6 deletions calendar/base/public/calIAlarmService.idl
Expand Up @@ -44,12 +44,6 @@ interface calIAlarmServiceObserver : nsISupports
[scriptable,uuid(42cfa9ce-49d6-11e5-b88c-5b90eedc1c47)]
interface calIAlarmService : nsISupports
{
/**
* Upper limit for the snooze period for an alarm. To avoid performance issues, don't change this
* to a value larger then 1 at least until bug 861594 or a similar concept is implemented.
*/
const unsigned long MAX_SNOOZE_MONTHS = 1;

/**
* This is the timezone that all-day events will be converted to in order to
* determine when their alarms should fire.
Expand Down
8 changes: 4 additions & 4 deletions calendar/base/src/calAlarmService.js
Expand Up @@ -241,14 +241,14 @@ calAlarmService.prototype = {
// a month ahead of an event, or doesn't start Lightning
// for a month, they'll miss some, but that's a slim chance
start = now.clone();
start.month -= Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
start.month -= 1;
this.alarmService.mRangeStart = start.clone();
} else {
// This is a subsequent search, so we got all the past alarms before
start = this.alarmService.mRangeEnd.clone();
}
let until = now.clone();
until.month += Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
until.month += 1;

// We don't set timers for every future alarm, only those within 6 hours
let end = now.clone();
Expand Down Expand Up @@ -569,8 +569,8 @@ calAlarmService.prototype = {
// for a month, they'll miss some, but that's a slim chance
let start = nowUTC();
let until = start.clone();
start.month -= Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
until.month += Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
start.month -= 1;
until.month += 1;
this.findAlarms(aCalendars, start, until);
},

Expand Down
4 changes: 0 additions & 4 deletions calendar/locales/en-US/chrome/calendar/calendar.properties
Expand Up @@ -450,10 +450,6 @@ alarmYesterdayAt=Yesterday at %1$S
alarmDefaultDescription=Default Mozilla Description
alarmDefaultSummary=Default Mozilla Summary

# LOCALIZATION NOTE (alarmSnoozeLimitExceeded): Semi-colon list of plural
# forms.
alarmSnoozeLimitExceeded=You cannot snooze an alarm for more than #1 month.;You cannot snooze an alarm for more than #1 months.

taskDetailsStatusNeedsAction=Needs Action

# LOCALIZATION NOTE (taskDetailsStatusInProgress):
Expand Down

0 comments on commit 0ba6f65

Please sign in to comment.