Skip to content

Commit

Permalink
Only redirect back to dapp if current tab is active
Browse files Browse the repository at this point in the history
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
  • Loading branch information
Gudahtt committed Dec 3, 2019
1 parent e25da41 commit 66e3020
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ export default class PermissionConnect extends Component {

if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_FULLSCREEN) {
setTimeout(async () => {
const { id: currentTabId } = await global.platform.currentTab()
const currentTab = await global.platform.currentTab()
try {
await global.platform.switchToTab(requestAccountTabs[originName])
if (currentTab.active) {
await global.platform.switchToTab(requestAccountTabs[originName])
}
} finally {
global.platform.closeTab(currentTabId)
global.platform.closeTab(currentTab.id)
}
}, 2000)
} else if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
Expand Down

0 comments on commit 66e3020

Please sign in to comment.