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

fix: check if returnTo is defined #8516

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/giant-zoos-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

Ensure returnTo value is defined before tracking analytics
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ export function LiveApp({ match, appId: propsAppId, location }: Props) {
}, [search, customDappUrl, urlParams?.customDappUrl, internalParams?.customDappUrl]);

const handleClose = useCallback(() => {
if (returnTo.startsWith("/swap")) {
if (typeof returnTo === "string" && returnTo.startsWith("/swap")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM like that, another option could have been to simply do that

Suggested change
if (typeof returnTo === "string" && returnTo.startsWith("/swap")) {
if (returnTo?.startsWith("/swap")) {

Also if you update the type in the memo above you can get typescript to show the undefined correctly as shown in the screenshot below
Screenshot 2024-11-28 at 09 21 11

Copy link
Contributor Author

@Couto Couto Nov 28, 2024

Choose a reason for hiding this comment

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

Just pushed this change.
The video in the description is still valid after this commit, according to my tests

track("button_click", {
...swapTrackingProperties,
button: "close X",
partner: appId,
page: "swap",
});
}

history.push(returnTo || `/platform`);
}, [history, returnTo, appId, swapTrackingProperties, track]);
const themeType = useTheme().colors.palette.type;
Expand Down
Loading