Open opto opened 2 months ago
Proposal as follows. I wanted to model this after the BrowserSettings API, but it isn't versatile enough for multi-entry settings like this. We can still put it in a settings namespace where we can later add other BrowserSettings type settings. I'm not sure we should key it on the name of the category, but it seems most logical given this is the unique key in the app and it doesn't make sense to have two categories with the same name.
@jobisoft what do you think?
let categories = await messenger.calendar.settings.categories.getAll();
/*
[{
name: "Meeting",
color: "#FFFF66"
}, {
...
}]
*/
let mtg = await messenger.calendar.settings.categories.get("Meeting");
/*
{
name: "Meeting",
color: "#FFFF66"
}
*/
await messenger.calendar.settings.categories.create({
name: "Meeting 2",
color: "#FF0000"
});
// Update to turn off the "use color" option
await messenger.calendar.settings.categories.update("Meeting 2", {
color: null
});
await messenger.calendar.settings.categories.remove("Meeting");
messenger.calendar.settings.categories.onCreated.addListener((category) => {
console.log(`Category ${category.name} created with color ${category.color}`);
});
messenger.calendar.settings.categories.onUpdated.addListener((category) => {
console.log(`Category ${category.name} updated with color ${category.color}`);
});
messenger.calendar.settings.categories.onRemoved.addListener((name) => {
// We could pass the category verbatim here as well.
console.log(`Category ${name} removed`);
});
fine, thanks. And please add events on create, update, etc., so that they can be propagated elsewhere. (That is missing on the tags, for example, I can propagate new tags only when they are applied to a message, but on webext I cannot discover when tags are added, updated, removed etc.)
Good point, added those to my last comment.
We can get the categories attached to items. It would be good to get a list of possible categories, colors etc, to set new ones and have the corresponding events.
Thanks Klaus/opto