Closed
Bug 313502
Opened 19 years ago
Closed 19 years ago
importer should notify observer with onBatchStart
Categories
(Calendar :: Internal Components, defect)
Calendar
Internal Components
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mvl, Assigned: mvl)
References
Details
Attachments
(4 files, 1 obsolete file)
9.18 KB,
patch
|
dmosedale
:
first-review-
|
Details | Diff | Splinter Review |
11.67 KB,
patch
|
dmosedale
:
first-review-
|
Details | Diff | Splinter Review |
12.18 KB,
patch
|
dmosedale
:
first-review-
|
Details | Diff | Splinter Review |
12.22 KB,
patch
|
dmosedale
:
first-review+
|
Details | Diff | Splinter Review |
Importing events is slow, because it doesn't tell anything that a batch of changes is coming. This means that the views will refresh after every item. This is very, very slow. Even slow enough to make this bug block 0.3a1
Assignee | ||
Comment 1•19 years ago
|
||
THis is one way of solving the problems. It moves the problem to the callers, which need to call startBatch. It also forces all providers to forward the call.
I think we have to go with this for now.
There are some other ways to solve the redrawing issue, but those are more complicated, and won't be fixed for 0.3a1.
(those other ways may be: making the views autodetect mass changes, making the view only redraw when the changed item is actually in the viewed daterange)
(other future improvement: a different observer infrastrure where there is a central 'hub', so that for example the batch notifications don't go through the providers)
Comment 2•19 years ago
|
||
Comment on attachment 200526 [details] [diff] [review]
patch v1
>Index: base/content/import-export.js
>===================================================================
>RCS file: /cvsroot/mozilla/calendar/base/content/import-export.js,v
>retrieving revision 1.4
>diff -u -9 -p -d -r1.4 import-export.js
>--- base/content/import-export.js 28 Sep 2005 18:28:24 -0000 1.4
>+++ base/content/import-export.js 23 Oct 2005 17:58:39 -0000
>@@ -110,21 +110,35 @@ function loadEventsFromFile()
> alert(getStringBundle().GetStringFromName("unableToRead") + filePath + "\n"+ex );
> }
>
> // XXX Ask for a calendar to import into
> var destCal = getDefaultCalendar();
>
> // XXX This might not work in lighting
> startBatchTransaction();
>
>+ destCal.startBatch();
>+
Since there are now two "startBatch"-type and two "endBatch"-type calls in a row, can you add commentary explaining that the outer one is for the undo/redo transaction manager batch?
>+ // This listener is needed to find out when the last addITem really
>+ // finished. Using a counter o find the last item (which might not
>+ // be the last item added)
>+ var count = 0;
>+ var listener = {
>+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
>+ count++;
>+ if (count == items.length)
>+ destCal.endBatch();
>+ }
>+ }
>+
> for each (item in items) {
> // XXX prompt when finding a duplicate.
>- destCal.addItem(item, null);
>+ destCal.addItem(item, listener);
> }
I think we need some sort of error-handling here. Can you put a try block around the addItem call as well as test the status in the callback, and cause an error dialog to be show if there's a problem in either case?
Attachment #200526 -
Flags: first-review?(dmose) → first-review-
Assignee | ||
Comment 3•19 years ago
|
||
updated import-export.js to review comments. Also remove the use of alert(), and replaced it with nsIPromptService.alert()
Attachment #200631 -
Flags: first-review?(dmose)
Comment 4•19 years ago
|
||
Comment on attachment 200631 [details] [diff] [review]
updated import-export.js
>+ // This listener is needed to find out when the last addItem really
>+ // finished. Using a counter o find the last item (which might not
>+ // be the last item added)
>+ var count = 0;
>+ var failedCount = 0;
>+ var lastError;
>+ var listener = {
>+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
>+ count++;
>+ // See if it is time to end the calendar's batch.
>+ if (count == items.length)
>+ destCal.endBatch();
>+ if (failedCount)
>+ showError(failedCount+" items failed to import. The last error was: "+lastError.toString());
>+ }
>+ }
There still needs to be a check of aStatus here, because errors are at least as likely to be called back this way than thrown during the initial call to addItem.
Attachment #200631 -
Flags: first-review?(dmose) → first-review-
Assignee | ||
Comment 5•19 years ago
|
||
updated patch to do an extra error check
Attachment #200785 -
Flags: first-review?(dmose)
Comment 6•19 years ago
|
||
Comment on attachment 200785 [details] [diff] [review]
v3
As nearly as I can tell, this patch is completely missing the diffs for the file that would have changed since the last version.
Attachment #200785 -
Flags: first-review?(dmose) → first-review-
Assignee | ||
Comment 7•19 years ago
|
||
Attachment #200785 -
Attachment is obsolete: true
Attachment #200911 -
Flags: first-review?(dmose)
Comment 8•19 years ago
|
||
Comment on attachment 200911 [details] [diff] [review]
now with import-export.js
Almost there!
>+ // This listener is needed to find out when the last addItem really
>+ // finished. Using a counter o find the last item (which might not
I bet "counter o" wants to be "counter to".
> for each (item in items) {
> // XXX prompt when finding a duplicate.
>- destCal.addItem(item, null);
>+ try {
>+ destCal.addItem(item, listener);
>+ } catch(e) {
>+ failedCount++;
>+ lastError = e;
>+ // Call the listener's operationComplete, to increase the
>+ // counter and not miss failed items. Otherwise, endBatch might
>+ // never be called.
>+ listener.onOperationComplete(null, null, null, null, null);
>+ throw (e);
>+ }
> }
If that catch clause is triggered on any item other than the last one, endBatch is guaranteed to never be called, because you throw immediately, so the for loop will never finish.
Attachment #200911 -
Flags: first-review?(dmose) → first-review-
Assignee | ||
Comment 9•19 years ago
|
||
replaced throw with Components.utils.reportError. That way there will still be a list of all errors somewhere, without showing 1000 dialogs
Attachment #201158 -
Flags: first-review?(dmose)
Comment 10•19 years ago
|
||
Comment on attachment 201158 [details] [diff] [review]
updated patch
r=dmose
Attachment #201158 -
Flags: first-review?(dmose) → first-review+
Assignee | ||
Comment 11•19 years ago
|
||
patch checked in
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•