mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Close notification on opening main UI
This commit is contained in:
parent
b3887ffd0a
commit
671ca33abb
@ -1,13 +1,14 @@
|
|||||||
const extension = require('./extension')
|
const extension = require('./extension')
|
||||||
|
|
||||||
const notifications = {
|
const notifications = {
|
||||||
show: showNotification,
|
show,
|
||||||
getPopup,
|
getPopup,
|
||||||
|
closePopup,
|
||||||
}
|
}
|
||||||
module.exports = notifications
|
module.exports = notifications
|
||||||
window.METAMASK_NOTIFIER = notifications
|
window.METAMASK_NOTIFIER = notifications
|
||||||
|
|
||||||
function showNotification() {
|
function show () {
|
||||||
getPopup((popup) => {
|
getPopup((popup) => {
|
||||||
if (popup) {
|
if (popup) {
|
||||||
return extension.windows.update(popup.id, { focused: true })
|
return extension.windows.update(popup.id, { focused: true })
|
||||||
@ -39,3 +40,9 @@ function getPopup(cb) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closePopup() {
|
||||||
|
getPopup((popup) => {
|
||||||
|
if (!popup) return
|
||||||
|
extension.windows.remove(popup.id, console.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@ const StreamProvider = require('web3-stream-provider')
|
|||||||
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
|
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
|
||||||
const isPopupOrNotification = require('./lib/is-popup-or-notification')
|
const isPopupOrNotification = require('./lib/is-popup-or-notification')
|
||||||
const extension = require('./lib/extension')
|
const extension = require('./lib/extension')
|
||||||
|
const notification = require('./lib/notifications')
|
||||||
|
|
||||||
// setup app
|
// setup app
|
||||||
var css = MetaMaskUiCss()
|
var css = MetaMaskUiCss()
|
||||||
@ -25,6 +26,7 @@ function connectToAccountManager (cb) {
|
|||||||
// setup communication with background
|
// setup communication with background
|
||||||
|
|
||||||
var name = isPopupOrNotification()
|
var name = isPopupOrNotification()
|
||||||
|
closePopupIfOpen(name)
|
||||||
window.METAMASK_UI_TYPE = name
|
window.METAMASK_UI_TYPE = name
|
||||||
var pluginPort = extension.runtime.connect({ name })
|
var pluginPort = extension.runtime.connect({ name })
|
||||||
var portStream = new PortStream(pluginPort)
|
var portStream = new PortStream(pluginPort)
|
||||||
@ -98,3 +100,8 @@ function setupApp (err, opts) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closePopupIfOpen(name) {
|
||||||
|
if (name !== 'notification') {
|
||||||
|
notification.closePopup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -253,7 +253,7 @@ function reduceApp (state, action) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
closePopupIfOpen()
|
notification.closePopup()
|
||||||
|
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
transForward: false,
|
transForward: false,
|
||||||
@ -520,9 +520,3 @@ function indexForPending (state, txId) {
|
|||||||
return idx
|
return idx
|
||||||
}
|
}
|
||||||
|
|
||||||
function closePopupIfOpen() {
|
|
||||||
notification.getPopup((popup) => {
|
|
||||||
if (!popup) return
|
|
||||||
extension.windows.remove(popup.id, console.error)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user