Add mark as spam / not spam to the thread list context menu #1011

This commit is contained in:
Ben Gotow 2018-08-14 19:03:53 -07:00
parent 33cf7b5b67
commit cfe39d3bab

View file

@ -31,6 +31,7 @@ export default class ThreadListContextMenu {
this.archiveItem(),
this.trashItem(),
this.markAsReadItem(),
this.markAsSpamItem(),
this.starItem(),
]);
})
@ -48,7 +49,9 @@ export default class ThreadListContextMenu {
if (this.threadIds.length !== 1) {
return null;
}
const from = this.threads[0].participants.find(p => !p.isMe());
const first = this.threads[0];
const from = first.participants.find(p => !p.isMe()) || first.participants[0];
return {
label: `Search for ${from.email}`,
click: () => {
@ -179,6 +182,28 @@ export default class ThreadListContextMenu {
};
}
markAsSpamItem() {
const allInSpam = this.threads.every(item => item.folders.find(c => c.role === 'spam'));
const dir = allInSpam ? 'Not Spam' : 'Spam';
return {
label: `Mark as ${dir}`,
click: () => {
Actions.queueTasks(
allInSpam
? TaskFactory.tasksForMarkingNotSpam({
source: 'Context Menu: Thread List',
threads: this.threads,
})
: TaskFactory.tasksForMarkingAsSpam({
source: 'Context Menu: Thread List',
threads: this.threads,
})
);
},
};
}
starItem() {
const starred = this.threads.every(t => t.starred === false);