Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions internal_packages/unread-notifications/lib/main.es6
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,18 @@ export class Notifier {

Promise.props(threads).then((resolvedThreads) => {
// Filter new unread messages to just the ones in the inbox
const newUnreadInInbox = newUnread.filter((msg) =>
resolvedThreads[msg.threadId] && resolvedThreads[msg.threadId].categoryNamed('inbox')
)
let newUnreadInInbox = newUnread.filter((msg) =>
resolvedThreads[msg.threadId] && (
resolvedThreads[msg.threadId].categoryNamed('inbox')
)
);
// Should we only notify on important messages?
if (NylasEnv.config.get("core.notifications.onlyImportant")) {
// Filter new unread messages to just the ones in the inbox that are marked important
newUnreadInInbox = newUnreadInInbox.filter((msg) =>
resolvedThreads[msg.threadId].categoryNamed('important')
);
}

// Filter messages that we can't decide whether to display or not
// since no associated Thread object has arrived yet.
Expand Down Expand Up @@ -196,6 +205,10 @@ export const config = {
'type': 'boolean',
'default': true,
},
onlyImportant: {
'type': 'boolean',
'default': false,
}
};

export function activate() {
Expand Down
5 changes: 5 additions & 0 deletions src/config-schema.es6
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ export default {
'default': true,
'title': "Play sound when receiving new mail",
},
onlyImportant: {
'type': 'boolean',
'default': false,
'title': "Only notify for messages considered important",
},
countBadge: {
'type': 'string',
'default': 'unread',
Expand Down