Skip to content
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

Open
opto opened this issue Sep 20, 2024 · 3 comments
Open

Calendar Settings API for categories #42

opto opened this issue Sep 20, 2024 · 3 comments
Labels
api: calendar This issue is about the calendar API experimeent proposal Issue contains a draft API proposal

Comments

@opto
Copy link

opto commented Sep 20, 2024

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

@kewisch
Copy link
Member

kewisch commented Sep 21, 2024

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`);
});

@kewisch kewisch added api: calendar This issue is about the calendar API experimeent proposal Issue contains a draft API proposal labels Sep 21, 2024
@kewisch kewisch changed the title Getter and setter for categories Calendar Settings API for categories Sep 21, 2024
@opto
Copy link
Author

opto commented Sep 21, 2024

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.)

@kewisch
Copy link
Member

kewisch commented Sep 21, 2024

Good point, added those to my last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: calendar This issue is about the calendar API experimeent proposal Issue contains a draft API proposal
Projects
None yet
Development

No branches or pull requests

2 participants