Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Switch network when shortName prefix changes #2832

Merged
merged 5 commits into from Oct 19, 2021

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Oct 13, 2021

What it solves

Resolves #2828

How this PR fixes it

A listener is attached to the history object which checks that a shortName exists and differs to the current config one. When it detects a change, it sets the new network.

How to test it

Open a safe on one network and connect, then open a safe on another network and connect. Click the back button and you should get prompted to connect to the previous network.

Accessing a NETWORK_ROOT_ROUTES route, i.e. .../app/polygon sets the app to that network. The network selector in the top right should still work on these routes that have no chain prefix in the URL.

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

e.preventDefault()
clickAway()
setNetwork(networkId)
// setNetwork occurs via history.listen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there's no shortName in the ROOT_ROUTE, is there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true - thanks for catching that!

@github-actions
Copy link

github-actions bot commented Oct 13, 2021

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 3 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

@iamacook iamacook marked this pull request as draft October 13, 2021 14:59
@iamacook iamacook marked this pull request as ready for review October 13, 2021 15:12
@francovenica
Copy link
Contributor

The PR is stuck loading for me:
https://pr2832--safereact.review-safe.gnosisdev.com/app/rinkeby/
image

@francovenica
Copy link
Contributor

The PR works now.

Looks good to me.

I loaded 2 safe, one in Rinkeby and one in xDai. and visited one after the other.
In both networks I'm connected automatically when switching.
I use the "Back" button of the browser to go from the xDai safe to the Rinkeby safe.

Result: the app now gives the option to change networks.
Gif:
10-18-2021_x(3163)

@iamacook iamacook merged commit 3e2fb19 into l2-ux Oct 19, 2021
@iamacook iamacook deleted the change-network-with-chain-prefix branch October 19, 2021 06:08
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[L2-UX]The user is back on the wrong network for the safe when back Browser option is used
3 participants