зеркало из https://github.com/mozilla/pjs.git
Bug 357079 - Agenda tab doesn't update today's date after hibernating, patch=mschroeder, r=mickey
This commit is contained in:
Родитель
6bb54afc76
Коммит
7c7a2f72dc
|
@ -25,6 +25,7 @@
|
|||
* gekacheka@yahoo.com
|
||||
* Matthew Willis <lilmatt@mozilla.com>
|
||||
* Philipp Kewisch <mozilla@kewis.ch>
|
||||
* Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -296,6 +297,8 @@ function getSelectedDay() {
|
|||
return currentView().selectedDay;
|
||||
}
|
||||
|
||||
var gMidnightTimer;
|
||||
|
||||
/** Creates a timer that will fire after midnight. Pass in a function as
|
||||
* aRefreshCallback that should be called at that time.
|
||||
*/
|
||||
|
@ -313,9 +316,33 @@ function scheduleMidnightUpdate(aRefreshCallback) {
|
|||
}
|
||||
};
|
||||
|
||||
var timer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
timer.initWithCallback(udCallback, msUntilTomorrow, timer.TYPE_ONE_SHOT);
|
||||
if (!gMidnightTimer) {
|
||||
// Observer for wake after sleep/hibernate/standby to create new timers and refresh UI
|
||||
var wakeObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "wake_notification") {
|
||||
aRefreshCallback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add observer
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
observerService.addObserver(wakeObserver, "wake_notification", false);
|
||||
|
||||
// Remove observer on unload
|
||||
window.addEventListener("unload",
|
||||
function() {
|
||||
observerService.removeObserver(wakeObserver, "wake_notification");
|
||||
}, false);
|
||||
|
||||
gMidnightTimer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(Components.interfaces.nsITimer);
|
||||
} else {
|
||||
gMidnightTimer.cancel();
|
||||
}
|
||||
gMidnightTimer.initWithCallback(udCallback, msUntilTomorrow, gMidnightTimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
// Returns the actual style sheet object with the specified path. Callers are
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* Matthew Willis <mattwillis@gmail.com>
|
||||
* Markus Adrario <MarkusAdrario@web.de>
|
||||
* Philipp Kewisch <mozilla@kewis.ch>
|
||||
* Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -89,7 +90,9 @@ var agendaTreeView = {
|
|||
todayCount: 0,
|
||||
tomorrowCount: 0,
|
||||
soonCount: 0,
|
||||
prevRowCount: 0
|
||||
prevRowCount: 0,
|
||||
refreshQueue: [],
|
||||
refreshPending: false
|
||||
};
|
||||
|
||||
agendaTreeView.init =
|
||||
|
@ -398,7 +401,13 @@ agendaTreeView.calendarOpListener.onOperationComplete =
|
|||
function listener_onOperationComplete(calendar, status, optype, id,
|
||||
detail)
|
||||
{
|
||||
this.agendaTreeView.calendarUpdateComplete();
|
||||
this.agendaTreeView.calendarUpdateComplete();
|
||||
|
||||
// signal that the current operation finished.
|
||||
this.agendaTreeView.refreshPending = false;
|
||||
|
||||
// immediately start the next job on the queue.
|
||||
this.agendaTreeView.popRefreshQueue();
|
||||
};
|
||||
|
||||
agendaTreeView.calendarOpListener.onGetResult =
|
||||
|
@ -410,9 +419,18 @@ function listener_onGetResult(calendar, status, itemtype, detail, count, items)
|
|||
items.forEach(this.agendaTreeView.addItem, this.agendaTreeView);
|
||||
};
|
||||
|
||||
agendaTreeView.refreshCalendarQuery =
|
||||
function refreshCalendarQuery()
|
||||
agendaTreeView.popRefreshQueue =
|
||||
function popRefreshQueue()
|
||||
{
|
||||
if (this.refreshPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
var refreshJob = this.refreshQueue.pop();
|
||||
if (!refreshJob) {
|
||||
return;
|
||||
}
|
||||
|
||||
var filter = this.calendar.ITEM_FILTER_CLASS_OCCURRENCES;
|
||||
if (document.getElementById("hide-completed-checkbox").checked) {
|
||||
filter |= this.calendar.ITEM_FILTER_COMPLETED_NO;
|
||||
|
@ -435,11 +453,20 @@ function refreshCalendarQuery()
|
|||
break;
|
||||
}
|
||||
|
||||
this.refreshPending = true;
|
||||
this.periods.forEach(function (p) { p.events = []; });
|
||||
this.calendar.getItems(filter, 0, this.today.start, this.soon.end,
|
||||
this.calendarOpListener);
|
||||
};
|
||||
|
||||
agendaTreeView.refreshCalendarQuery =
|
||||
function refreshCalendarQuery()
|
||||
{
|
||||
var refreshJob = {};
|
||||
this.refreshQueue.push(refreshJob);
|
||||
this.popRefreshQueue();
|
||||
};
|
||||
|
||||
agendaTreeView.updateFilter =
|
||||
function updateAgendaFilter(menulist) {
|
||||
this.filterType = menulist.selectedItem.value;
|
||||
|
|
Загрузка…
Ссылка в новой задаче