Closed Bug 1693873 Opened 4 years ago Closed 3 years ago

Investigate replacing calIOperationListener with the DOM Streams API

Categories

(Calendar :: Internal Components, enhancement)

enhancement

Tracking

(thunderbird_esr91 wontfix, thunderbird98 affected)

RESOLVED FIXED
96 Branch
Tracking Status
thunderbird_esr91 --- wontfix
thunderbird98 --- affected

People

(Reporter: lasana, Assigned: lasana)

References

(Blocks 1 open bug, Regression)

Details

Attachments

(7 files, 1 obsolete file)

The calIOperationListener interface is an important interface in the calendar component.

It is used to both get results from reads, and be notified off writes completion to a calendar. It is however, a bit complicated to grasp at first, not to mention verbose.
Example:
https://searchfox.org/comm-central/source/calendar/providers/ics/CalICSCalendar.jsm#317

Use of this interface for reading seems to be based around streaming results rather than providing them all at once. Now that there is a standard streaming api coming to browsers, it's probably worth consideration.

https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
https://streams.spec.whatwg.org/

I have not looked into this in much detail yet but sharing my thoughts.

Depends on: 1474543

WritableStream isn't ready yet but ReadableStream exists. I think we can benefit from some cleaner code if we return this instead of using callbacks. I'm going to add a method to calICalendar for querying that will return a stream.

Assignee: nobody → lasana
Type: defect → enhancement

I'm going to do some additional work here to make some of the calICalendar return promises.

Status: NEW → ASSIGNED
Attachment #9250016 - Attachment is obsolete: true
Attachment #9250444 - Attachment description: Bug 1693873 - Have calICalendar.getItem return a Promise. r=darktrojan → WIP: Bug 1693873 - Have calICalendar.getItem return a Promise. r=darktrojan
Attachment #9250444 - Attachment description: WIP: Bug 1693873 - Have calICalendar.getItem return a Promise. r=darktrojan → Bug 1693873 - Have calICalendar.getItem return a Promise. r=darktrojan
Attachment #9250444 - Attachment description: Bug 1693873 - Have calICalendar.getItem return a Promise. r=darktrojan → Bug 1693873 - Part 1: Have calICalendar.getItem return a Promise. r=darktrojan

Let's get part 1 in, this bug is likely to become unwieldy the longer it takes to land.

Target Milestone: --- → 96 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/c610b77b74e9
Part 1: Have calICalendar.getItem return a Promise. r=darktrojan

Ok this is proving exponentially more difficult than it started. The relationship between the storage calendar, cached calendar and the caldav calendar is way too complex and roundabout. I'm scaling doing my next patches.

Attachment #9252029 - Attachment description: WIP: Bug 1693873 - Part 3: Convert addItem() adoptItem() and affected apis to Promises. r=darktrojan → WIP: Bug 1693873 - Part 3: Convert addItem() adoptItem() to use Promises. r=darktrojan

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/245a295b4e97
Part 2: Convert deleteItem(), getItemOfflineFlag() and deleteOfflineItem() to Promises. r=darktrojan

Attachment #9252029 - Attachment description: WIP: Bug 1693873 - Part 3: Convert addItem() adoptItem() to use Promises. r=darktrojan → Bug 1693873 - Part 3: Convert addItem() adoptItem() to Promises. r=darktrojan
Attachment #9252958 - Attachment description: WIP: Bug 1693873 - Part 4: Convert modifyItem() to use Promises. r=darktrojan → Bug 1693873 - Part 4: Convert modifyItem() to use Promises. r=darktrojan
Attachment #9252958 - Attachment description: Bug 1693873 - Part 4: Convert modifyItem() to use Promises. r=darktrojan → Bug 1693873 - Part 4: Convert modifyItem() to Promises. r=darktrojan

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/b3db46c32bc3
Part 3: Convert addItem() adoptItem() to Promises. r=darktrojan
https://hg.mozilla.org/comm-central/rev/cba80602d505
Part 4: Convert modifyItem() to Promises. r=darktrojan

Attachment #9255343 - Attachment description: WIP: Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan → Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan
Attachment #9255343 - Attachment description: Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan → WIP: Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan
Depends on: 1749547
No longer depends on: 1474543
Attachment #9255343 - Attachment description: WIP: Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan → Bug 1693873 - Part 5: Convert getItems() to return a ReadableStream. r=darktrojan
Blocks: 1751802

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/8d5f9a37e98e
Part 5: Convert getItems() to return a ReadableStream. r=darktrojan

Regressions: 1752043
Keywords: leave-open

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/2ad2d6a1dbc4
Part 6 - Make all calIOfflineStorage methods use promises. r=darktrojan.
https://hg.mozilla.org/comm-central/rev/15f448d138dc
Part 7: Remove calAsyncUtils.jsm. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Regressions: 1745745
Regressions: 1754898
No longer regressions: 1754898
Regressed by: 1754898
Regressions: 1758112
Regressions: 1765247
Regressions: 1770446
Regressions: 1769200

Part 3: Convert addItem() adoptItem() to Promises. r=darktrojan

 // This is a needed hack to keep the cached calendar's "onAddItem" event
 // firing before the endBatch() call of the uncached calendar. It is called
 // in mUncachedCalendar's adoptItem() method.

I don't suppose you can still remember why this was necessary? I couldn't see what it was doing from the code, since all of the adoptItem() methods invoke it as the very last thing, in which case surely this caller could just perform the operation itself? I notice one comment (which seems to have become detached from the comment that it's answering) in the review which mentions a test that might be relevant; do you remember which test it was?

Flags: needinfo?(lasana)

It's browser_caldavCalendar_cached.js the order of the onAddItem event in a batch needs to be kept. Changes to this part of the code base just landed. You might also want to check out the add-on updating guide if you have not already.

https://github.com/thundernest/developer-docs/blob/master/add-ons/updating/tb102/adapt-to-changes-in-thunderbird-92-102.md#calicalendar

Flags: needinfo?(lasana)
Regressions: 1794471
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: