sync-engine icon indicating copy to clipboard operation
sync-engine copied to clipboard

When updating threads, should be able to specify just the labels that are being added/removed

Open thomasst opened this issue 9 years ago • 5 comments

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.

thomasst avatar Feb 04 '16 23:02 thomasst

You would want add_labels and remove_labels ?

grinich avatar Feb 05 '16 01:02 grinich

Yes, that would solve the problem and make it easier to add/remove a label.

thomasst avatar Feb 05 '16 01:02 thomasst

Or probably add_label_ids and remove_label_ids

grinich avatar Feb 07 '16 03:02 grinich

(internal https://sentry.nylas.com/sentry/edgehill/group/10371/ )

grinich avatar Feb 07 '16 03:02 grinich

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.

thomasst avatar Feb 07 '16 03:02 thomasst