diff --git a/internal_packages/preferences/lib/tabs/preferences-notifications.cjsx b/internal_packages/preferences/lib/tabs/preferences-notifications.cjsx index b713905bf..22a0ad70f 100644 --- a/internal_packages/preferences/lib/tabs/preferences-notifications.cjsx +++ b/internal_packages/preferences/lib/tabs/preferences-notifications.cjsx @@ -24,10 +24,10 @@ class PreferencesNotifications extends React.Component

@props.config.toggle('unread-notifications.enabled')}/> - + id="core.notifications.enabled" + checked={@props.config.get('core.notifications.enabled')} + onChange={ => @props.config.toggle('core.notifications.enabled')}/> +

@@ -38,10 +38,10 @@ class PreferencesNotifications extends React.Component

@props.config.toggle('unread-notifications.sounds')}/> - + id="core.notifications.sounds" + checked={@props.config.get('core.notifications.sounds')} + onChange={ => @props.config.toggle('core.notifications.sounds')}/> +

new Promise (resolve, reject) => - return resolve() if atom.config.get('unread-notifications.enabled') is false + return resolve() if atom.config.get('core.notifications.enabled') is false incomingMessages = incoming['message'] ? [] incomingThreads = incoming['thread'] ? [] @@ -95,7 +95,7 @@ module.exports = threads[msg.threadId]?.categoryNamed('inbox') isnt null return resolve() if newUnreadInInbox.length is 0 - if atom.config.get("unread-notifications.sounds") + if atom.config.get("core.notifications.sounds") SoundRegistry.playSound('new-mail') for msg in newUnreadInInbox diff --git a/internal_packages/unread-notifications/spec/main-spec.coffee b/internal_packages/unread-notifications/spec/main-spec.coffee index 4298bd847..9892573fb 100644 --- a/internal_packages/unread-notifications/spec/main-spec.coffee +++ b/internal_packages/unread-notifications/spec/main-spec.coffee @@ -173,23 +173,23 @@ describe "UnreadNotifications", -> it "should play a sound when it gets new mail", -> spyOn(atom.config, "get").andCallFake (config) -> - if config is "unread-notifications.enabled" then return true - if config is "unread-notifications.sounds" then return true + if config is "core.notifications.enabled" then return true + if config is "core.notifications.sounds" then return true spyOn(SoundRegistry, "playSound") waitsForPromise => Main._onNewMailReceived({message: [@msg1]}) .then -> - expect(atom.config.get.calls[1].args[0]).toBe "unread-notifications.sounds" + expect(atom.config.get.calls[1].args[0]).toBe "core.notifications.sounds" expect(SoundRegistry.playSound).toHaveBeenCalledWith("new-mail") it "should not play a sound if the config is off", -> spyOn(atom.config, "get").andCallFake (config) -> - if config is "unread-notifications.enabled" then return true - if config is "unread-notifications.sounds" then return false + if config is "core.notifications.enabled" then return true + if config is "core.notifications.sounds" then return false spyOn(SoundRegistry, "playSound") waitsForPromise => Main._onNewMailReceived({message: [@msg1]}) .then -> - expect(atom.config.get.calls[1].args[0]).toBe "unread-notifications.sounds" + expect(atom.config.get.calls[1].args[0]).toBe "core.notifications.sounds" expect(SoundRegistry.playSound).not.toHaveBeenCalled() diff --git a/src/config-schema.coffee b/src/config-schema.coffee index b67293c04..bac021fb4 100644 --- a/src/config-schema.coffee +++ b/src/config-schema.coffee @@ -53,3 +53,12 @@ module.exports = type: 'string' default: 'reply-all' enum: ['reply', 'reply-all'] + notifications: + type: 'object' + properties: + enabled: + type: 'boolean' + default: true + sounds: + type: 'boolean' + default: true