Skip to content

Commit

Permalink
Only redirect back to dapp if current tab is active (#7621)
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 authored Dec 3, 2019
1 parent c5b85aa commit b1915aa
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 b1915aa

Please sign in to comment.