aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-09-02 02:22:29 +0800
committerDan Finlay <dan@danfinlay.com>2016-09-02 02:26:27 +0800
commit47b2ae1c5f51b41f832931e18599f5f9ae25a378 (patch)
treef0c6c6ca3756cd084d413b72263fd2097139e085 /app/scripts/lib
parentd26dd53fe18f43fc509f828348e013147159da91 (diff)
downloadtangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar.gz
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar.bz2
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar.lz
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar.xz
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.tar.zst
tangerine-wallet-browser-47b2ae1c5f51b41f832931e18599f5f9ae25a378.zip
Do not open popup for internally produced txs
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/notifications.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index 432ad0445..87d758e3b 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -9,11 +9,12 @@ module.exports = notifications
window.METAMASK_NOTIFIER = notifications
function show () {
- getPopup((popup) => {
- if (popup) {
- return extension.windows.update(popup.id, { focused: true })
- }
+ getWindows((windows) => {
+ if (windows.length > 0) {
+ const win = windows[0]
+ return extension.windows.update(win.id, { focused: true })
+ }
extension.windows.create({
url: 'notification.html',
@@ -25,22 +26,29 @@ function show () {
})
}
-function getPopup(cb) {
-
+function getWindows(cb) {
// Ignore in test environment
if (!extension.windows) {
- return cb(null)
+ return cb()
}
extension.windows.getAll({}, (windows) => {
- let popup = windows.find((win) => {
- return win.type === 'popup'
- })
+ cb(null, windows)
+ })
+}
- cb(popup)
+function getPopup(cb) {
+ getWindows((windows) => {
+ cb(getPopupIn(windows))
})
}
+function getPopupIn(windows) {
+ return windows ? windows.find((win) => {
+ return win.type === 'popup'
+ }) : null
+}
+
function closePopup() {
getPopup((popup) => {
if (!popup) return