Mailspring/internal_packages/notification-mailto/lib/main.coffee
Ben Gotow 9378f4480c fix(naming): Move atom/inbox/nilas refs to Nylas
Conflicts:
	internal_packages/inbox-activity-bar/lib/activity-bar-long-poll-item.cjsx
2015-05-15 11:07:28 -07:00

47 lines
1.4 KiB
CoffeeScript

{Actions} = require 'nylas-exports'
LaunchServices = require './launch-services'
NOTIF_ACTION_YES = 'mailto:set-default-yes'
NOTIF_ACTION_NO = 'mailto:set-default-no'
module.exports =
activate: (@state) ->
@services = new LaunchServices()
# We can't do anything unless they're on Mac OS X
return unless @services.available()
# We shouldn't ask if they've already said No
return if atom.config.get('inbox.mailto.prompted-about-default') is true
@services.isRegisteredForURLScheme 'mailto', (registered) =>
# Prompt them to make Inbox their default client
unless registered
@_unlisten = Actions.notificationActionTaken.listen(@_onNotificationActionTaken, @)
Actions.postNotification
type: 'info',
sticky: true
message: "Thanks for trying out Nylas Mail! Would you like to make it your default mail client?",
icon: 'fa-inbox',
actions: [{
label: 'Yes'
id: NOTIF_ACTION_YES
},{
label: 'Not Now'
id: NOTIF_ACTION_NO
}]
deactivate: ->
@_unlisten()
serialize: -> @state
_onNotificationActionTaken: ({notification, action}) ->
if action.id is NOTIF_ACTION_YES
@services.registerForURLScheme 'mailto', (err) ->
console.log(err) if err
if action.id is NOTIF_ACTION_NO
atom.config.set('inbox.mailto.prompted-about-default', true)