fix(config): new mail sounds on by default, change config keypath

unread-notifications.sounds => core.notifications.sounds
This commit is contained in:
Ben Gotow 2015-10-14 17:11:36 -07:00
parent ff34e7c5e8
commit 31991d370e
4 changed files with 25 additions and 16 deletions

View file

@ -24,10 +24,10 @@ class PreferencesNotifications extends React.Component
</p>
<p>
<input type="checkbox"
id="unread-notifications.enabled"
checked={@props.config.get('unread-notifications.enabled')}
onChange={ => @props.config.toggle('unread-notifications.enabled')}/>
<label htmlFor="unread-notifications.enabled">Show notifications for new unread messages</label>
id="core.notifications.enabled"
checked={@props.config.get('core.notifications.enabled')}
onChange={ => @props.config.toggle('core.notifications.enabled')}/>
<label htmlFor="core.notifications.enabled">Show notifications for new unread messages</label>
</p>
</div>
</div>
@ -38,10 +38,10 @@ class PreferencesNotifications extends React.Component
<div className="section-body">
<p>
<input type="checkbox"
id="unread-notifications.sounds"
checked={@props.config.get('unread-notifications.sounds')}
onChange={ => @props.config.toggle('unread-notifications.sounds')}/>
<label htmlFor="unread-notifications.sounds">Play sound when receiving new mail</label>
id="core.notifications.sounds"
checked={@props.config.get('core.notifications.sounds')}
onChange={ => @props.config.toggle('core.notifications.sounds')}/>
<label htmlFor="core.notifications.sounds">Play sound when receiving new mail</label>
</p>
<p>
<input type="checkbox"

View file

@ -63,7 +63,7 @@ module.exports =
_onNewMailReceived: (incoming) ->
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

View file

@ -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()

View file

@ -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