-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calendar Settings API for categories #42
Comments
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. |
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
The text was updated successfully, but these errors were encountered: