diff --git a/calendar/resources/content/calendarWindow.js b/calendar/resources/content/calendarWindow.js index fd478840bf0..22d593789c1 100644 --- a/calendar/resources/content/calendarWindow.js +++ b/calendar/resources/content/calendarWindow.js @@ -140,6 +140,17 @@ function CalendarWindow( ) var savedThis = this; var calendarObserver = { + QueryInterface: function (aIID) { + if (!aIID.equals(Components.interfaces.nsISupports) && + !aIID.equals(Components.interfaces.calICompositeObserver) && + !aIID.equals(Components.interfaces.calIObserver)) + { + throw Components.results.NS_ERROR_NO_INTERFACE; + } + + return this; + }, + mInBatch: false, onStartBatch: function() { @@ -166,7 +177,17 @@ function CalendarWindow( ) calendarWindow.currentView.refreshEvents(); }, onAlarm: function(aAlarmItem) {}, - onError: function(aMessage) {} + onError: function(aMessage) {}, + + onCalendarAdded: function(aDeletedItem) { + if (!this.mInBatch) + calendarWindow.currentView.refreshEvents(); + }, + onCalendarRemoved: function(aDeletedItem) { + if (!this.mInBatch) + calendarWindow.currentView.refreshEvents(); + }, + onDefaultCalendarChanged: function(aNewDefaultCalendar) {} } var ccalendar = getDisplayComposite(); ccalendar.addObserver(calendarObserver); diff --git a/calendar/resources/content/unifinder.js b/calendar/resources/content/unifinder.js index 5829b4e2bd9..966e6d71b54 100644 --- a/calendar/resources/content/unifinder.js +++ b/calendar/resources/content/unifinder.js @@ -138,6 +138,7 @@ var unifinderObserver = { QueryInterface: function (aIID) { if (!aIID.equals(Components.interfaces.nsISupports) && + !aIID.equals(Components.interfaces.calICompositeObserver) && !aIID.equals(Components.interfaces.calIObserver)) { throw Components.results.NS_ERROR_NO_INTERFACE; @@ -170,7 +171,17 @@ var unifinderObserver = { refreshEventTree(); }, onAlarm: function(aAlarmItem) {}, - onError: function(aMessage) {} + onError: function(aMessage) {}, + + onCalendarAdded: function(aDeletedItem) { + if (!this.mInBatch) + refreshEventTree(); + }, + onCalendarRemoved: function(aDeletedItem) { + if (!this.mInBatch) + refreshEventTree(); + }, + onDefaultCalendarChanged: function(aNewDefaultCalendar) {} }; diff --git a/calendar/resources/content/unifinderToDo.js b/calendar/resources/content/unifinderToDo.js index a46776f23e9..e0015763ca0 100644 --- a/calendar/resources/content/unifinderToDo.js +++ b/calendar/resources/content/unifinderToDo.js @@ -59,33 +59,57 @@ var gTaskArray = new Array(); var unifinderToDoDataSourceObserver = { - onStartBatch: function () { }, - onEndBatch: function () { + mInBatch: false, + + QueryInterface: function (aIID) { + if (!aIID.equals(Components.interfaces.nsISupports) && + !aIID.equals(Components.interfaces.calICompositeObserver) && + !aIID.equals(Components.interfaces.calIObserver)) + { + throw Components.results.NS_ERROR_NO_INTERFACE; + } + + return this; + }, + + onStartBatch: function() { + this.mInBatch = true; + }, + onEndBatch: function() { + this.mInBatch = false; toDoUnifinderRefresh(); }, - - onLoad: function () { - toDoUnifinderRefresh(); + onLoad: function() { + if (!this.mInBatch) + refreshEventTree(); }, - - onAddItem: function (aItem) { - if (aItem instanceof Components.interfaces.calITodo) + onAddItem: function(aItem) { + if (aItem instanceof Components.interfaces.calITodo && + !this.mInBatch) toDoUnifinderRefresh(); }, - - onModifyItem: function (aNewItem, aOldItem) { - if (aNewItem instanceof Components.interfaces.calITodo) + onModifyItem: function(aNewItem, aOldItem) { + if (aNewItem instanceof Components.interfaces.calITodo && + !this.mInBatch) toDoUnifinderRefresh(); }, - - onDeleteItem: function (aItem) { - if (aItem instanceof Components.interfaces.calITodo) + onDeleteItem: function(aDeletedItem) { + if (aDeletedItem instanceof Components.interfaces.calITodo && + !this.mInBatch) toDoUnifinderRefresh(); }, + onAlarm: function(aAlarmItem) {}, + onError: function(aMessage) {}, - onAlarm: function (aAlarmItem) { }, - - onError: function (aErrNo, aMessage) { } + onCalendarAdded: function(aDeletedItem) { + if (!this.mInBatch) + toDoUnifinderRefresh(); + }, + onCalendarRemoved: function(aDeletedItem) { + if (!this.mInBatch) + toDoUnifinderRefresh(); + }, + onDefaultCalendarChanged: function(aNewDefaultCalendar) {} }; /**