Skip to content

Commit 0f471cb

Browse files
committed
fix: clean up
1 parent 4cf3892 commit 0f471cb

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

app/components/UI/TokenDetails/Views/TokenDetails.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ describe('TokenDetails', () => {
10471047
}
10481048
});
10491049

1050-
it('shares only the token symbol when caip19AssetId cannot be resolved', async () => {
1050+
it('does not share when caip19AssetId cannot be resolved', async () => {
10511051
mockRouteParams.mockReturnValue({
10521052
...defaultRouteParams,
10531053
chainId: undefined,
@@ -1056,9 +1056,7 @@ describe('TokenDetails', () => {
10561056
render(<TokenDetails />);
10571057
await invokeSharePress();
10581058

1059-
const [args] = (Share.share as jest.Mock).mock.calls[0];
1060-
expect(args.message).toBe('DAI');
1061-
expect(args.url).toBeUndefined();
1059+
expect(Share.share).not.toHaveBeenCalled();
10621060
});
10631061

10641062
it('resolves caip19AssetId directly when address is already CAIP-19 format', async () => {

app/components/UI/TokenDetails/Views/TokenDetails.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,11 @@ const TokenDetails: React.FC<{
197197
const isPriceAlertsFeatureEnabled = useSelector(selectPriceAlertsEnabled);
198198

199199
const handleShare = useCallback(() => {
200-
const url = caip19AssetId
201-
? `https://link.metamask.io/asset?assetId=${encodeURIComponent(caip19AssetId)}`
202-
: undefined;
200+
if (!caip19AssetId) {
201+
return;
202+
}
203+
204+
const url = `https://link.metamask.io/asset?assetId=${encodeURIComponent(caip19AssetId)}`;
203205

204206
trackEvent(
205207
createEventBuilder(MetaMetricsEvents.TOKEN_DETAILS_SHARED)
@@ -211,12 +213,9 @@ const TokenDetails: React.FC<{
211213
.build(),
212214
);
213215

214-
// iOS renders `url` as a rich link preview; Android needs it in `message`
215-
Share.share(
216-
Platform.OS === 'ios'
217-
? { message: token.symbol, url }
218-
: { message: url ?? token.symbol },
219-
);
216+
// Share only the deep link. iOS renders `url` as a rich link preview;
217+
// Android needs the link in `message`.
218+
Share.share(Platform.OS === 'ios' ? { url } : { message: url });
220219
}, [
221220
caip19AssetId,
222221
createEventBuilder,

0 commit comments

Comments
 (0)