Skip to content

Commit

Permalink
fix: check result of permission requests, fix #161
Browse files Browse the repository at this point in the history
  • Loading branch information
SunriseFox authored and Jack-Works committed Sep 18, 2019
1 parent b23e71b commit 287f3c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/extension/options-page/Welcome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const WelcomeActions = {
// This request MUST BE sync or Firefox will reject this request
return browser.permissions
.request({ origins: json.grantedHostPermissions })
.then(() => Services.People.restoreBackup(json, id))
.then(granted =>
granted
? Services.People.restoreBackup(json, id)
: Promise.reject(new Error('required permission is not granted.')),
)
},
autoVerifyBio(network: PersonIdentifier, provePost: string) {
getCurrentNetworkWorkerService(network).autoVerifyBio(network, provePost)
Expand Down
13 changes: 9 additions & 4 deletions src/social-network-provider/facebook.com/ui-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ defineSocialNetworkUI({
return location.hostname.endsWith('facebook.com')
},
friendlyName: 'Facebook',
async setupAccount() {
await browser.permissions.request({ origins: ['https://www.facebook.com/*', 'https://m.facebook.com/*'] })
await setStorage('facebook.com', { forceDisplayWelcome: true })
location.href = 'https://facebook.com/'
setupAccount() {
browser.permissions
.request({ origins: ['https://www.facebook.com/*', 'https://m.facebook.com/*'] })
.then(granted => {
if (granted) {
setStorage('facebook.com', { forceDisplayWelcome: true })
location.href = 'https://facebook.com/'
}
})
},
ignoreSetupAccount() {
setStorage('facebook.com', { userIgnoredWelcome: true, forceDisplayWelcome: false })
Expand Down
17 changes: 11 additions & 6 deletions src/social-network-provider/twitter.com/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ export const instanceOfTwitterUI = defineSocialNetworkUI({
return location.hostname.endsWith(host)
},
friendlyName: 'Twitter (Developing...)',
setupAccount: async () => {
await browser.permissions.request({
origins: [`${hostURL}/*`, `${hostMobileURL}/*`],
})
setStorage(host, { forceDisplayWelcome: true }).then()
window.open(hostURL as string)
setupAccount: () => {
browser.permissions
.request({
origins: [`${hostURL}/*`, `${hostMobileURL}/*`],
})
.then(granted => {
if (granted) {
setStorage(host, { forceDisplayWelcome: true }).then()
window.open(hostURL as string)
}
})
},
ignoreSetupAccount() {
setStorage(host, { userIgnoredWelcome: true }).then()
Expand Down

0 comments on commit 287f3c8

Please sign in to comment.