Skip to content
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

[txns] Fix navigation in transactions with back #965

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

rs-8
Copy link
Contributor

@rs-8 rs-8 commented Dec 20, 2024

Hello!

Fix back navigation in transactions page

For the first navigation to transactions, a replacement is used so that you can exit with one click

Navigations between user and all transactions work as usual

Before:

Screen.Recording.2024-12-20.at.12.24.25.mov

After

Screen.Recording.2024-12-20.at.12.39.39.mov

Thanks!

Copy link
Contributor

@kaw2k kaw2k left a comment

Choose a reason for hiding this comment

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

Thank you for the before and after, and for contributing!

Comment on lines 18 to 28
useEffect(() => {
if (userTxnOnly) {
if (isGraphqlClientSupported && !searchParams.get("type")) {
searchParams.set("type", "user");
return setSearchParams(searchParams, {replace: true});
}

if (!isGraphqlClientSupported && !searchParams.get("type")) {
searchParams.set("type", "all");
return setSearchParams(searchParams, {replace: true});
}
}, [isGraphqlClientSupported, searchParams, setSearchParams, allTxnOnly]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a touch of cleanup here:

  • Looks like we no longer need allTxnOnly so we can omit it from the dependency array
  • You should only return a cleanup function from useEffect, otherwise, avoid returns.

I suggest the following:

useEffect(() => {
  if (!searchParams.get("type")) {
    searchParams.set("type", isGraphqlClientSupported ? "user" : "all");
    setSearchParams(searchParams, { replace: true });
  }
}, [isGraphqlClientSupported, searchParams, setSearchParams]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks correct and simpler, added changes to pull request
Thank you for review

Copy link
Contributor

@kaw2k kaw2k left a comment

Choose a reason for hiding this comment

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

Excelent, thank you!

@kaw2k kaw2k merged commit 64c092b into aptos-labs:main Jan 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants