Add option for unsnoozed messages to show as unread. (#267)

This commit is contained in:
Jeffrey Smith II 2017-10-29 20:35:16 -04:00 committed by Ben Gotow
parent 0af31a64c4
commit 614bc198c5
3 changed files with 22 additions and 1 deletions

View file

@ -8,7 +8,7 @@ import {
Thread,
} from 'mailspring-exports';
import { moveThreads, snoozedUntilMessage } from './snooze-utils';
import { markUnreadIfSet, moveThreads, snoozedUntilMessage } from './snooze-utils';
import { PLUGIN_ID } from './snooze-constants';
import SnoozeActions from './snooze-actions';
@ -91,6 +91,9 @@ class SnoozeStore extends MailspringStore {
// move the threads back to the inbox
moveThreads(threads, { snooze: false, description: 'Unsnoozed' });
// mark the threads unread if setting is enabled
markUnreadIfSet(threads, 'Unsnoozed message');
// remove the expiration on the metadata. note this is super important,
// otherwise we'll receive a notification from the sync worker over and
// over again.

View file

@ -52,3 +52,16 @@ export function moveThreads(threads, { snooze, description } = {}) {
Actions.queueTasks(tasks);
}
export function markUnreadIfSet(threads, source) {
if (AppEnv.config.get('core.notifications.unreadOnSnooze')) {
Actions.queueTask(
TaskFactory.taskForSettingUnread({
unread: true,
threads: threads,
source: source,
canBeUndone: true,
})
);
}
}

View file

@ -158,6 +158,11 @@ export default {
default: true,
title: 'Play sound when receiving new mail',
},
unreadOnSnooze: {
type: 'boolean',
default: false,
title: 'Mark a message unread when returning from snooze',
},
countBadge: {
type: 'string',
default: 'unread',