Skip to content

Commit

Permalink
Update reading_list.md
Browse files Browse the repository at this point in the history
Updates the schema to reflect the current state of implementation on the readingList api
  • Loading branch information
dlbjames authored Aug 18, 2023
1 parent ee5562d commit 73b2e38
Showing 1 changed file with 94 additions and 40 deletions.
134 changes: 94 additions & 40 deletions proposals/reading_list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# New API: browser.readingList()
Contributors: [email protected]

## Background

Expand Down Expand Up @@ -26,41 +27,56 @@ The `browser.readingList` will introduce a few new types and functions. Below is
## Types
A ReadingListEntry is the extensions representation of a Reading List object. Where every URL stored in the Reading List must be unique.
```js
dictionary ReadingListEntry {
// The url of the entry.
DOMString url;
// The title of the entry.
DOMString title;
// True if the entry has been read.
boolean hasBeenRead;
// The last update time of the entry.
// Recorded in microseconds since Jan 1st 1970.
double lastUpdateTime;
// The creation time of the entry.
// Recorded in microseconds since Jan 1st 1970.
double creationTime;
};
```

dictionary ReadingListEntry {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
AddEntryOptions are the objects used to add entries into the Reading List.
```js
dictionary AddEntryOptions {
// The url of the entry.
DOMString url;
// The title of the entry.
DOMString title;
// True if the entry has been read.
boolean hasBeenRead;
}
};

```

A QueryInfo is the object used to query for ReadingListEntries in the Reading List.
```js
dictionary QueryInfo {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
DOMString? url;
// The title to query for.
DOMString? title;
// The read status to query for.
boolean? hasBeenRead;
// The url to query for.
DOMString? url;
// The title to query for.
DOMString? title;
// The read status to query for.
boolean? hasBeenRead;
}
```
An UpdateEntryOptions is the object used to update a specific ReadingListEntry in the Reading List. A URL must be supplied.
```js
dictionary UpdateEntryOptions {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
DOMString url;
// The updated title.
DOMString? title;
// The updated read status.
boolean? hasBeenRead;
// The url that will be updated.
DOMString url;
// The updated title.
DOMString? title;
// The updated read status.
boolean? hasBeenRead;
}
```
Expand Down Expand Up @@ -121,6 +137,32 @@ The initially supported functions of the API.

```
## Events
The initially supported events this api will emit.
### onEntryAdded()
> Triggered when a ReadingListEntry was added to the reading list.
>
> |entry|: The entry that was added.
```js
static void onEntryAdded(ReadingListEntry entry);
```
### onEntryWillBeRemoved()
> Triggered when a ReadingListEntry is about to be removed from the
> reading list.
>
> |entry|: The entry that will be removed.
```js
static void onEntryWillBeRemoved(ReadingListEntry entry);
```
### onEntryUpdated()
> Triggered when a ReadingListEntry was updated in the reading list.
>
> |entry|: The entry that was updated.
```js
static void onEntryUpdated(ReadingListEntry entry);
```
### Additional Considerations
#### Incognito mode
Expand All @@ -132,33 +174,30 @@ The `browser.readingList` API can be available in incognito mode assuming the us
```js
namespace readingList {
dictionary ReadingListEntry {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
DOMString url;
// The title of the entry.
DOMString title;
// True if the entry has been read.
boolean hasBeenRead;
}
// The url of the entry.
DOMString url;
// The title of the entry.
DOMString title;
// True if the entry has been read.
boolean hasBeenRead;
};

dictionary QueryInfo {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
DOMString? url;
// The title to query for.
DOMString? title;
// The read status to query for.
boolean? hasBeenRead;
// The url to query for.
DOMString? url;
// The title to query for.
DOMString? title;
// The read status to query for.
boolean? hasBeenRead;
}

dictionary UpdateEntryOptions {
// The url of the entry. Must have a valid protocol (Ex: http, https)
// and hostname (Ex: www.google.com). Can contain query parameters.
DOMString url;
// The updated title.
DOMString? title;
// The updated read status.
boolean? hasBeenRead;
// The url that will be updated.
DOMString url;
// The updated title.
DOMString? title;
// The updated read status.
boolean? hasBeenRead;
}

callback AddEntryCallback = void ();
Expand All @@ -180,6 +219,21 @@ dictionary UpdateEntryOptions {
// Updates a reading list entries title and hasBeenRead status if it exists.
[supportsPromises] static void updateEntry(UpdateEntryOptions info, UpdateEntryCallback callback);
};

interface Events {
// Triggered when a ReadingListEntry was added to the reading list.
// |entry|: The entry that was added.
static void onEntryAdded(ReadingListEntry entry);

// Triggered when a ReadingListEntry is about to be removed from the
// reading list.
// |entry|: The entry that will be removed.
static void onEntryWillBeRemoved(ReadingListEntry entry);

// Triggered when a ReadingListEntry was updated in the reading list.
// |entry|: The entry that was updated.
static void onEntryUpdated(ReadingListEntry entry);
};
};
```

0 comments on commit 73b2e38

Please sign in to comment.