Skip to content

Commit

Permalink
fix: multi permisison dialogs for the same permission
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Apr 6, 2018
1 parent 7ad01fb commit 37d8f9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion add-on/src/lib/ipfs-proxy/request-access.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
'use strict'

const { piggyback } = require('piggybacker')

const DIALOG_WIDTH = 540
const DIALOG_HEIGHT = 220
const DIALOG_PATH = 'dist/pages/proxy-access-dialog/index.html'
const DIALOG_PORT_NAME = 'proxy-access-dialog'

function createRequestAccess (browser, screen) {
return async function requestAccess (scope, permission, opts) {
// piggybacker allows multiple requests for access to the same permission to
// receive the same response i.e. don't popup multiple dialogs for the
// same permission request.
return piggyback(requestAccess, (scope, permission) => `${scope}/${permission}`)

async function requestAccess (scope, permission, opts) {
opts = opts || {}

const url = browser.extension.getURL(opts.dialogPath || DIALOG_PATH)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"lru_map": "0.3.3",
"mime-types": "2.1.18",
"p-queue": "2.3.0",
"piggybacker": "^2.0.0",
"prundupify": "1.0.0",
"tachyons": "4.9.1",
"webextension-polyfill": "0.1.2"
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7169,6 +7169,10 @@ pify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"

piggybacker@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/piggybacker/-/piggybacker-2.0.0.tgz#571526babe029cf7332fa5d96ee010ad5da88787"

pinkie-promise@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
Expand Down

0 comments on commit 37d8f9b

Please sign in to comment.