aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/notifications.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index b72939196..90edaea12 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -8,24 +8,30 @@ module.exports = {
createMsgNotification: createMsgNotification,
}
-// guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236
-if (!chrome.notifications) return console.error('Chrome notifications API missing...')
+setupListeners()
-// 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)
-})
+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 teardown
-chrome.notifications.onClosed.addListener(function(notificationId){
- delete notificationHandlers[notificationId]
-})
+ // 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]
+ })
+
+}
// creation helper
function createUnlockRequestNotification(opts){