From 90f494c9a1f822436d4b3cd5f9ddd52f27e43378 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 2 Jun 2016 17:29:49 -0700 Subject: fix illegal return statement :( --- app/scripts/lib/notifications.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'app/scripts') 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){ -- cgit