mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-28 23:44:38 +08:00
fix(deps): Remove nodobjc until we re-enable native notifications
This commit is contained in:
parent
6a79bc58dc
commit
d12af16583
3 changed files with 95 additions and 99 deletions
|
@ -43,7 +43,6 @@
|
||||||
"moment": "^2.8",
|
"moment": "^2.8",
|
||||||
"moment-timezone": "^0.3",
|
"moment-timezone": "^0.3",
|
||||||
"nslog": "^2.0.0",
|
"nslog": "^2.0.0",
|
||||||
"NodObjC": "git+https://github.com/TooTallNate/NodObjC",
|
|
||||||
"node-uuid": "^1.4",
|
"node-uuid": "^1.4",
|
||||||
"optimist": "0.4.0",
|
"optimist": "0.4.0",
|
||||||
"pathwatcher": "^4.4.0",
|
"pathwatcher": "^4.4.0",
|
||||||
|
|
|
@ -3,7 +3,6 @@ BrowserWindow = require 'browser-window'
|
||||||
WindowManager = require './window-manager'
|
WindowManager = require './window-manager'
|
||||||
ApplicationMenu = require './application-menu'
|
ApplicationMenu = require './application-menu'
|
||||||
AutoUpdateManager = require './auto-update-manager'
|
AutoUpdateManager = require './auto-update-manager'
|
||||||
NativeNotificationManager = require './native-notification-manager'
|
|
||||||
NylasProtocolHandler = require './nylas-protocol-handler'
|
NylasProtocolHandler = require './nylas-protocol-handler'
|
||||||
SharedFileManager = require './shared-file-manager'
|
SharedFileManager = require './shared-file-manager'
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ class Application
|
||||||
client.on 'error', createApplication
|
client.on 'error', createApplication
|
||||||
|
|
||||||
windowManager: null
|
windowManager: null
|
||||||
notificationManager: null
|
|
||||||
applicationMenu: null
|
applicationMenu: null
|
||||||
nylasProtocolHandler: null
|
nylasProtocolHandler: null
|
||||||
resourcePath: null
|
resourcePath: null
|
||||||
|
@ -89,7 +87,6 @@ class Application
|
||||||
@devMode = true
|
@devMode = true
|
||||||
|
|
||||||
@windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode})
|
@windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode})
|
||||||
@notificationManager = new NativeNotificationManager()
|
|
||||||
@autoUpdateManager = new AutoUpdateManager(@version, @config, @specMode)
|
@autoUpdateManager = new AutoUpdateManager(@version, @config, @specMode)
|
||||||
@applicationMenu = new ApplicationMenu(@version)
|
@applicationMenu = new ApplicationMenu(@version)
|
||||||
@_databasePhase = 'setup'
|
@_databasePhase = 'setup'
|
||||||
|
|
|
@ -1,95 +1,95 @@
|
||||||
ipc = require 'ipc'
|
# ipc = require 'ipc'
|
||||||
BrowserWindow = require 'browser-window'
|
# BrowserWindow = require 'browser-window'
|
||||||
|
#
|
||||||
class NativeNotificationManagerUnavailable
|
# class NativeNotificationManagerUnavailable
|
||||||
|
#
|
||||||
class NativeNotificationManagerWindows
|
# class NativeNotificationManagerWindows
|
||||||
constructor: ->
|
# constructor: ->
|
||||||
|
#
|
||||||
class NativeNotificationManagerMacOSX
|
# class NativeNotificationManagerMacOSX
|
||||||
constructor: ->
|
# constructor: ->
|
||||||
@$ = require('nodobjc')
|
# @$ = require('nodobjc')
|
||||||
@$.framework('Foundation')
|
# @$.framework('Foundation')
|
||||||
|
#
|
||||||
@_lastNotifId = 1
|
# @_lastNotifId = 1
|
||||||
|
#
|
||||||
@_center = @$.NSUserNotificationCenter('defaultUserNotificationCenter')
|
# @_center = @$.NSUserNotificationCenter('defaultUserNotificationCenter')
|
||||||
@_center('removeAllDeliveredNotifications')
|
# @_center('removeAllDeliveredNotifications')
|
||||||
|
#
|
||||||
Delegate = @$.NSObject.extend('NylasNotificationDelegate')
|
# Delegate = @$.NSObject.extend('NylasNotificationDelegate')
|
||||||
Delegate.addMethod('userNotificationCenter:didActivateNotification:', [@$.void, [Delegate, @$.selector, @$.id, @$.id]], @didActivateNotification)
|
# Delegate.addMethod('userNotificationCenter:didActivateNotification:', [@$.void, [Delegate, @$.selector, @$.id, @$.id]], @didActivateNotification)
|
||||||
Delegate.addMethod('userNotificationCenter:shouldPresentNotification:', ['c', [Delegate, @$.selector, @$.id, @$.id]], @shouldPresentNotification)
|
# Delegate.addMethod('userNotificationCenter:shouldPresentNotification:', ['c', [Delegate, @$.selector, @$.id, @$.id]], @shouldPresentNotification)
|
||||||
Delegate.register()
|
# Delegate.register()
|
||||||
@_delegate = Delegate('alloc')('init')
|
# @_delegate = Delegate('alloc')('init')
|
||||||
@_center('setDelegate', @_delegate)
|
# @_center('setDelegate', @_delegate)
|
||||||
|
#
|
||||||
# Ensure that these objects are never, ever garbage collected
|
# # Ensure that these objects are never, ever garbage collected
|
||||||
global.__nativeNotificationManagerMacOSXDelegate = Delegate
|
# global.__nativeNotificationManagerMacOSXDelegate = Delegate
|
||||||
global.__nativeNotificationManagerMacOSX = @
|
# global.__nativeNotificationManagerMacOSX = @
|
||||||
|
#
|
||||||
ipc.on('fire-native-notification', @onFireNotification)
|
# ipc.on('fire-native-notification', @onFireNotification)
|
||||||
|
#
|
||||||
shouldPresentNotification: (self, _cmd, center, notif) =>
|
# shouldPresentNotification: (self, _cmd, center, notif) =>
|
||||||
return true
|
# return true
|
||||||
|
#
|
||||||
didActivateNotification: (self, _cmd, center, notif) =>
|
# didActivateNotification: (self, _cmd, center, notif) =>
|
||||||
center("removeDeliveredNotification", notif)
|
# center("removeDeliveredNotification", notif)
|
||||||
|
#
|
||||||
[header, id, tag] = (""+notif('identifier')).split(':::')
|
# [header, id, tag] = (""+notif('identifier')).split(':::')
|
||||||
|
#
|
||||||
# Avoid potential conflicts with other libraries that may have pushed
|
# # Avoid potential conflicts with other libraries that may have pushed
|
||||||
# notifications on our behalf.
|
# # notifications on our behalf.
|
||||||
return unless header is 'N1'
|
# return unless header is 'N1'
|
||||||
|
#
|
||||||
NSUserNotificationActivationType = [
|
# NSUserNotificationActivationType = [
|
||||||
"none",
|
# "none",
|
||||||
"contents-clicked",
|
# "contents-clicked",
|
||||||
"action-clicked",
|
# "action-clicked",
|
||||||
"replied",
|
# "replied",
|
||||||
"additional-action-clicked"
|
# "additional-action-clicked"
|
||||||
]
|
# ]
|
||||||
|
#
|
||||||
payload =
|
# payload =
|
||||||
tag: tag
|
# tag: tag
|
||||||
activationType: NSUserNotificationActivationType[(""+notif('activationType'))/1]
|
# activationType: NSUserNotificationActivationType[(""+notif('activationType'))/1]
|
||||||
|
#
|
||||||
if payload.activationType is "replied"
|
# if payload.activationType is "replied"
|
||||||
payload.response = (""+notif('response')).replace("{\n}", '')
|
# payload.response = (""+notif('response')).replace("{\n}", '')
|
||||||
if payload.response is "null"
|
# if payload.response is "null"
|
||||||
payload.response = null
|
# payload.response = null
|
||||||
|
#
|
||||||
console.log("Received notification: " + JSON.stringify(payload))
|
# console.log("Received notification: " + JSON.stringify(payload))
|
||||||
BrowserWindow.getAllWindows().forEach (win) ->
|
# BrowserWindow.getAllWindows().forEach (win) ->
|
||||||
win.webContents.send('activate-native-notification', payload)
|
# win.webContents.send('activate-native-notification', payload)
|
||||||
|
#
|
||||||
onFireNotification: (event, {title, subtitle, body, tag, canReply}) =>
|
# onFireNotification: (event, {title, subtitle, body, tag, canReply}) =>
|
||||||
# By default on Mac OS X, delivering another notification with the same identifier
|
# # By default on Mac OS X, delivering another notification with the same identifier
|
||||||
# triggers an update, which does not re-display the notification. To make subsequent
|
# # triggers an update, which does not re-display the notification. To make subsequent
|
||||||
# calls with the same `tag` redisplay the notification, we:
|
# # calls with the same `tag` redisplay the notification, we:
|
||||||
|
#
|
||||||
# 1. Assign each notification a unique identifier, so it's not considered an update
|
# # 1. Assign each notification a unique identifier, so it's not considered an update
|
||||||
identifier = "N1:::#{@_lastNotifId}:::#{tag}"
|
# identifier = "N1:::#{@_lastNotifId}:::#{tag}"
|
||||||
@_lastNotifId += 1
|
# @_lastNotifId += 1
|
||||||
|
#
|
||||||
# 2. Manually remove any previous notification with the same tag
|
# # 2. Manually remove any previous notification with the same tag
|
||||||
delivered = @_center("deliveredNotifications")
|
# delivered = @_center("deliveredNotifications")
|
||||||
for existing in delivered
|
# for existing in delivered
|
||||||
[x, x, existingTag] = (""+existing('identifier')).split(':::')
|
# [x, x, existingTag] = (""+existing('identifier')).split(':::')
|
||||||
if existingTag is tag
|
# if existingTag is tag
|
||||||
@_center('removeDeliveredNotification', existing)
|
# @_center('removeDeliveredNotification', existing)
|
||||||
|
#
|
||||||
# 3. Fire a new notification
|
# # 3. Fire a new notification
|
||||||
notification = @$.NSUserNotification('alloc')('init')
|
# notification = @$.NSUserNotification('alloc')('init')
|
||||||
notification('setTitle', @$.NSString('stringWithUTF8String', title))
|
# notification('setTitle', @$.NSString('stringWithUTF8String', title))
|
||||||
notification('setIdentifier', @$.NSString('stringWithUTF8String', identifier))
|
# notification('setIdentifier', @$.NSString('stringWithUTF8String', identifier))
|
||||||
notification('setSubtitle', @$.NSString('stringWithUTF8String', subtitle)) if subtitle
|
# notification('setSubtitle', @$.NSString('stringWithUTF8String', subtitle)) if subtitle
|
||||||
notification('setInformativeText', @$.NSString('stringWithUTF8String', body)) if body
|
# notification('setInformativeText', @$.NSString('stringWithUTF8String', body)) if body
|
||||||
notification('setHasReplyButton', canReply)
|
# notification('setHasReplyButton', canReply)
|
||||||
@_center('deliverNotification', notification)
|
# @_center('deliverNotification', notification)
|
||||||
|
#
|
||||||
if process.platform is 'darwin'
|
# if process.platform is 'darwin'
|
||||||
module.exports = NativeNotificationManagerMacOSX
|
# module.exports = NativeNotificationManagerMacOSX
|
||||||
else if process.platform is 'win32'
|
# else if process.platform is 'win32'
|
||||||
module.exports = NativeNotificationManagerWindows
|
# module.exports = NativeNotificationManagerWindows
|
||||||
else
|
# else
|
||||||
module.exports = NativeNotificationManagerUnavailable
|
# module.exports = NativeNotificationManagerUnavailable
|
||||||
|
|
Loading…
Add table
Reference in a new issue