aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/notifications.js
diff options
context:
space:
mode:
authorFrankie <email": null>2016-06-06 22:20:05 +0800
committerFrankie <email": null>2016-06-06 22:20:05 +0800
commit2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5 (patch)
treecef049dd3e409d1beb23cc316c7f43b47fac3d93 /app/scripts/lib/notifications.js
parentf59ca7a6bf42b0cae70aab838a08a7d15e192d10 (diff)
parent5d9ced3c058d44524f37600bea076ca09da1d9bd (diff)
downloadtangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar.gz
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar.bz2
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar.lz
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar.xz
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.tar.zst
tangerine-wallet-browser-2c2fcd60bfc28c7e500c3cb5e7243cafb8f388e5.zip
Merge branch 'master' into uiFixes
Diffstat (limited to 'app/scripts/lib/notifications.js')
-rw-r--r--app/scripts/lib/notifications.js43
1 files changed, 29 insertions, 14 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index d011d778b..90edaea12 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -8,24 +8,35 @@ module.exports = {
createMsgNotification: createMsgNotification,
}
-// notification button press
-chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex){
- var handlers = notificationHandlers[notificationId]
- if (buttonIndex === 0) {
- handlers.confirm()
- } else {
- handlers.cancel()
- }
- chrome.notifications.clear(notificationId)
-})
+setupListeners()
+
+function setupListeners(){
+
+ // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
+ if (!chrome.notifications) return console.error('Chrome notifications API missing...')
+
+ // notification button press
+ chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex){
+ var handlers = notificationHandlers[notificationId]
+ if (buttonIndex === 0) {
+ handlers.confirm()
+ } else {
+ handlers.cancel()
+ }
+ chrome.notifications.clear(notificationId)
+ })
+
+ // notification teardown
+ chrome.notifications.onClosed.addListener(function(notificationId){
+ delete notificationHandlers[notificationId]
+ })
-// notification teardown
-chrome.notifications.onClosed.addListener(function(notificationId){
- delete notificationHandlers[notificationId]
-})
+}
// creation helper
function createUnlockRequestNotification(opts){
+ // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
+ if (!chrome.notifications) return console.error('Chrome notifications API missing...')
var message = 'An Ethereum app has requested a signature. Please unlock your account.'
var id = createId()
@@ -39,6 +50,8 @@ function createUnlockRequestNotification(opts){
}
function createTxNotification(opts){
+ // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
+ if (!chrome.notifications) return console.error('Chrome notifications API missing...')
var message = [
'Submitted by '+opts.txParams.origin,
'to: '+uiUtils.addressSummary(opts.txParams.to),
@@ -67,6 +80,8 @@ function createTxNotification(opts){
}
function createMsgNotification(opts){
+ // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
+ if (!chrome.notifications) return console.error('Chrome notifications API missing...')
var message = [
'Submitted by '+opts.msgParams.origin,
'to be signed by: '+uiUtils.addressSummary(opts.msgParams.from),