mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 01:54:40 +08:00
fix(config): new mail sounds on by default, change config keypath
unread-notifications.sounds => core.notifications.sounds
This commit is contained in:
parent
615e90466b
commit
aca9de07d9
4 changed files with 25 additions and 16 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue