aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-09-15 01:59:31 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-09-15 02:31:59 +0800
commiteea77b828fdaecb07fdc704edbcac0f42c771d27 (patch)
tree80fc4fad46b2695b138c01f1abc096a577891092 /app
parent56bdccc76d7ead5ee7aaa77e7a649d8a85f288b2 (diff)
downloadtangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar.gz
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar.bz2
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar.lz
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar.xz
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.tar.zst
tangerine-wallet-browser-eea77b828fdaecb07fdc704edbcac0f42c771d27.zip
Dont generate a popup notification when submiting a transaction from with in MetaMask
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js28
1 files changed, 11 insertions, 17 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 58228a41a..18a112dd1 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -10,31 +10,22 @@ const MetamaskController = require('./metamask-controller')
const extension = require('./lib/extension')
const STORAGE_KEY = 'metamask-config'
-
+var popupIsOpen = false
const controller = new MetamaskController({
// User confirmation callbacks:
- showUnconfirmedMessage,
- unlockAccountMessage,
- showUnconfirmedTx,
+ showUnconfirmedMessage: triggerUi,
+ unlockAccountMessage: triggerUi,
+ showUnconfirmedTx: triggerUi,
// Persistence Methods:
setData,
loadData,
})
const idStore = controller.idStore
-function unlockAccountMessage () {
- notification.show()
-}
-
-function showUnconfirmedMessage (msgParams, msgId) {
- notification.show()
+function triggerUi () {
+ if (!popupIsOpen) notification.show()
}
-
-function showUnconfirmedTx (txParams, txData, onTxDoneCb) {
- notification.show()
-}
-
// On first install, open a window to MetaMask website to how-it-works.
extension.runtime.onInstalled.addListener(function (details) {
@@ -53,7 +44,8 @@ function connectRemote (remotePort) {
var portStream = new PortStream(remotePort)
if (isMetaMaskInternalProcess) {
// communication with popup
- setupTrustedCommunication(portStream, 'MetaMask')
+ remotePort.name === 'popup' ? popupIsOpen = true : popupIsOpen = false
+ setupTrustedCommunication(portStream, 'MetaMask', remotePort.name)
} else {
// communication with page
var originDomain = urlUtil.parse(remotePort.sender.url).hostname
@@ -69,12 +61,13 @@ function setupUntrustedCommunication (connectionStream, originDomain) {
controller.setupPublicConfig(mx.createStream('publicConfig'))
}
-function setupTrustedCommunication (connectionStream, originDomain) {
+function setupTrustedCommunication (connectionStream, originDomain, metamaskContext) {
// setup multiplexing
var mx = setupMultiplex(connectionStream)
// connect features
setupControllerConnection(mx.createStream('controller'))
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
+ if (metamaskContext === 'popup') popupIsOpen = true
}
//
@@ -95,6 +88,7 @@ function setupControllerConnection (stream) {
// teardown on disconnect
eos(stream, () => {
controller.ethStore.removeListener('update', controller.sendUpdate.bind(controller))
+ popupIsOpen = false
})
})
}