When updating threads, should be able to specify just the labels that are being added/removed
In order to add or remove a label to a Gmail thread, you currently have to fetch the thread to get the list of labels, then client-side add/remove the labels you want to apply, then resubmit the new list of labels in the label_ids array.
However, we've seen race conditions where a label change is synced to Nylas in between the two client requests, causing Nylas to potentially undo label changes made by a user or throwing errors like The "sent" label cannot be changed even though we didn't mean to do anything with the sent label.
You would want add_labels and remove_labels ?
Yes, that would solve the problem and make it easier to add/remove a label.
Or probably add_label_ids and remove_label_ids
(internal https://sentry.nylas.com/sentry/edgehill/group/10371/ )
IDs is fine, although being able to use the name like all/inbox would make it even easier for developers. We currently 1) determine whether it's a Gmail or IMAP account, 2) fetch the list labels or folders depending on the account type and cache that information, 3) perform the category updates. We also have an exception handler that updates the category cache if there was an error. Being able to just use the inbox identifier would avoid all of this, but that's probably a discussion for a separate issue.