fix(moves): Improve labeling of ChangeLabelTasks

This commit is contained in:
Ben Gotow 2016-06-09 18:21:08 -07:00
parent aba4b7d6b9
commit 147f7f7219

View file

@ -54,19 +54,25 @@ export default class ChangeLabelsTask extends ChangeMailTask {
// factory and pass the string in as this.taskDescription (ala Snooze), but // factory and pass the string in as this.taskDescription (ala Snooze), but
// it's nice to have them declaratively based on the actual labels. // it's nice to have them declaratively based on the actual labels.
if (objectsAvailable) { if (objectsAvailable) {
if (this.labelsToAdd.length === 1 && this.labelsToRemove.length > 0) { const looksLikeMove = (this.labelsToAdd.length === 1 && this.labelsToRemove.length > 0);
// Spam / trash interactions are always "moves" because they're the three
// folders of Gmail. If another folder is involved, we need to decide to
// return either "Moved to Bla" or "Added Bla".
if (added && added.name === 'spam') {
return `Marked${countString} as Spam`;
} else if (removed && removed.name === 'spam') {
return `Unmarked${countString} as Spam`;
} else if (added && added.name === 'trash') {
return `Trashed${countString}`;
} else if (removed && removed.name === 'trash') {
return `Removed${countString} from Trash`;
}
if (looksLikeMove) {
if (added.name === 'all') { if (added.name === 'all') {
return `Archived${countString}`; return `Archived${countString}`;
} else if (removed.name === 'all') { } else if (removed.name === 'all') {
return `Unarchived${countString}`; return `Unarchived${countString}`;
} else if (added.name === 'spam') {
return `Marked${countString} as Spam`;
} else if (removed.name === 'spam') {
return `Unmarked${countString} as Spam`;
} else if (added.name === 'trash') {
return `Trashed${countString}`;
} else if (removed.name === 'trash') {
return `Removed${countString} from Trash`;
} }
return `Moved${countString} to ${added.displayName}`; return `Moved${countString} to ${added.displayName}`;
} }