Skip to content

Commit

Permalink
fix: response for multiple acl dialogs get mixed up
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Apr 6, 2018
1 parent b4a1688 commit ca758a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion add-on/src/lib/ipfs-proxy/request-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function createRequestAccess (browser, screen) {
const userResponse = new Promise((resolve, reject) => {
onPortConnect = port => {
if (port.name !== dialogPortName) return
if (!port.sender || !port.sender.tab || port.sender.tab.id !== tabId) return

browser.runtime.onConnect.removeListener(onPortConnect)

Expand Down Expand Up @@ -88,7 +89,10 @@ function createRequestAccess (browser, screen) {
let onTabRemoved

const userTabRemoved = new Promise((resolve, reject) => {
onTabRemoved = () => reject(new Error(`Failed to obtain access response for ${permission} at ${scope}`))
onTabRemoved = (id) => {
if (id !== tabId) return
reject(new Error(`Failed to obtain access response for ${permission} at ${scope}`))
}
browser.tabs.onRemoved.addListener(onTabRemoved)
})

Expand Down

0 comments on commit ca758a6

Please sign in to comment.