Skip to content

Commit

Permalink
feat(lld,llm/nft/stax): align custom lock screen entrypoint condition (
Browse files Browse the repository at this point in the history
…#4932)

* feat(lld,llm/nft/stax): align custom lock screen entrypoint condition

* fix(llm/NftLinksPanel): text wrapping properly
  • Loading branch information
ofreyssinet-ledger authored Oct 10, 2023
1 parent 006d9ff commit 9d8c602
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/cold-rats-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

NFT screen/Stax: only display "custom lock screen" option if the user has connected a Stax once
16 changes: 11 additions & 5 deletions apps/ledger-live-desktop/src/renderer/hooks/useNftLinks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { TFunction } from "i18next";
import { useTranslation } from "react-i18next";
import { Account, ProtoNFT, NFTMetadata, NFTMedias } from "@ledgerhq/types-live";
Expand All @@ -14,6 +14,8 @@ import { setDrawer } from "../drawers/Provider";
import CustomImage from "~/renderer/screens/customImage";
import NFTViewerDrawer from "~/renderer/drawers/NFTViewerDrawer";
import { ContextMenuItemType } from "../components/ContextMenu/ContextMenuWrapper";
import { devicesModelListSelector } from "../reducers/settings";
import { DeviceModelId } from "@ledgerhq/devices";

function safeList(items: (ContextMenuItemType | "" | undefined)[]): ContextMenuItemType[] {
return items.filter(Boolean) as ContextMenuItemType[];
Expand Down Expand Up @@ -166,21 +168,25 @@ export default (
}, [account, customImageUri, isInsideDrawer, nft.id, t]);

const customImageEnabled = useFeature("customImage")?.enabled;
const devicesModelList = useSelector(devicesModelListSelector);
const links = useMemo(() => {
const metadataLinks = linksPerCurrency[account.currency.id]?.(t, metadata?.links) || [];
return [
...metadataLinks,
...(customImageEnabled && customImageUri ? [customImage] : []),
...(devicesModelList?.includes(DeviceModelId.stax) && customImageEnabled && customImageUri
? [customImage]
: []),
hideCollection,
];
}, [
account.currency.id,
hideCollection,
t,
metadata?.links,
customImageUri,
devicesModelList,
customImageEnabled,
customImageUri,
customImage,
t,
hideCollection,
]);
return links;
};
8 changes: 6 additions & 2 deletions apps/ledger-live-mobile/src/components/Nft/NftLinksPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { rgba } from "../../colors";
import HideNftDrawer from "./HideNftDrawer";
import { track, TrackScreen } from "../../analytics";
import { extractImageUrlFromNftMetadata } from "../CustomImage/imageUtils";
import { knownDeviceModelIdsSelector } from "../../reducers/settings";
import { useSelector } from "react-redux";

type Props = {
links?: NFTMetadata["links"] | null;
Expand Down Expand Up @@ -51,7 +53,7 @@ const NftLink = ({
<LinkTouchable style={style} onPress={onPress}>
<Flex flexDirection="row" alignItems="center">
<Box mr={16}>{leftIcon}</Box>
<Flex flexDirection="column">
<Flex flexDirection="column" flexShrink={1}>
<Text fontWeight="semiBold" fontSize={16} color={primary ? "primary.c90" : "neutral.c100"}>
{title}
</Text>
Expand All @@ -76,8 +78,10 @@ const NftLinksPanel = ({ nftContract, nftId, links, isOpen, onClose, nftMetadata
useFeature("disableNftRaribleOpensea")?.enabled && Platform.OS === "ios";

const customImageUri = extractImageUrlFromNftMetadata(nftMetadata);
const knownDeviceModelIds = useSelector(knownDeviceModelIdsSelector);

const showCustomImageButton = customImage?.enabled && !!customImageUri;
const showCustomImageButton =
knownDeviceModelIds.stax && customImage?.enabled && !!customImageUri;

const handleOpenOpenSea = useCallback(() => {
track("button_clicked", {
Expand Down

0 comments on commit 9d8c602

Please sign in to comment.