Skip to content

Commit

Permalink
bugfix(recover): fix custom uri hook (#5466)
Browse files Browse the repository at this point in the history
* bugfix: fix custom uri hook

* bugfix(recover): replace default id by prod env

* bugfix(recover): request modification
  • Loading branch information
stephane-lieumont-ledger authored and lvndry committed Nov 16, 2023
1 parent 24075c6 commit 042665f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-hotels-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/live-common": patch
---

Fix issue on URL constructor when we use hook useCustomPath
9 changes: 5 additions & 4 deletions libs/ledger-live-common/src/hooks/recoverFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ export function useCustomPath(
source?: string,
deeplinkCampaign?: string,
): string | undefined {
const modelUri = usePostOnboardingURI(servicesConfig);
const customUri = useMemo(() => {
const [basicUri] = modelUri ? modelUri.split("?") : [];
const id = servicesConfig?.params?.protectId;
const basicUri = id ? `ledgerlive://recover/${id}` : "ledgerlive://recover/protect-prod";
const uri = new URL(basicUri);

if (page) uri.searchParams.append("redirectTo", page);
Expand All @@ -173,8 +173,9 @@ export function useCustomPath(
uri.searchParams.append("ajs_recover_source", source);
uri.searchParams.append("ajs_recover_campaign", deeplinkCampaign);
}

return uri;
}, [deeplinkCampaign, modelUri, page, source]);
}, [deeplinkCampaign, page, servicesConfig?.params?.protectId, source]);

return usePath(servicesConfig, customUri.toString()) ?? undefined;
return usePath(servicesConfig, customUri.toString());
}

0 comments on commit 042665f

Please sign in to comment.