-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(web): appUrl query was getting lost while switching network in safeApp #5081
base: dev
Are you sure you want to change the base?
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
@@ -92,6 +93,10 @@ export const getNetworkLink = (router: NextRouter, safeAddress: string, networkS | |||
route.query.safeViewRedirectURL = router.query?.safeViewRedirectURL.toString() | |||
} | |||
|
|||
if (router.query?.appUrl) { | |||
route.query.appUrl = router.query.appUrl.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This preserves the query indeed but ignores the fact that a Safe App might be not enabled on all chains.
From the original issue requirements:
Providing the Safe App is present on the destination chain, the Safe App should remain open, otherwise the dashboard navigated to, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking the same. However, in the case of other EOAs, when we switch to a different network within an app, it's the app that indicates it as an unsupported network.
Since we're displaying the app within Safe's dashboard, I guess it's a better user experience for Safe to indicate an unsupported network. Working on this fix !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the unsupported chain handling logic in apps/web/src/pages/apps/open.tsx
:
In this commit 8211879
Key Modifications:
- Refined the condition to check when
safeApp.chainIds
is empty - Maintained 3-second redirect timeout
- ensured the
remoteSafeAppsLoading
is false before we check for chainIds
Video Preview
Screen.Recording.2025-02-23.at.10.11.45.PM.mov
Let me know if any thing else needs to be updated @katspaugh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
apps/web/src/pages/apps/open.tsx
Outdated
setTimeout(() => { | ||
router.push({ | ||
pathname: AppRoutes.apps.index, | ||
query: { safe: router.query.safe }, | ||
}) | ||
}, 3000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done in a useEffect.
apps/web/src/pages/apps/open.tsx
Outdated
p={2} | ||
> | ||
<Typography variant="body1" gutterBottom> | ||
Chain {chainId} is not supported in this app. <br /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we display chainName here? It can be taken from useCurrentChain()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure let me just do that instead!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated fix:
- Using
useEffect
for routing back to safeApp Dashboard - Displaying chain name instead of chainId using
useCurrentChain()
check it out here: c288de4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much!
Sending to our QA.
Not sure why the cypress tests failed @katspaugh |
@chiranjeev13 that's normal, they can't run on external forks. |
What it solves
Resolves #4980
How this PR fixes it
In File apps/web/src/components/common/NetworkSelector/index.tsx
How to test it
yarn workspace @safe-global/web start
create a safe multi chain account
go inside a safeApp
switch network in there
Screenshots
Screen.Recording.2025-02-23.at.1.40.51.AM.mov
Checklist