Skip to content

Commit 8dba033

Browse files
✨ feat(lld): fetch assets data on search
1 parent e21c8cd commit 8dba033

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

.changeset/long-roses-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ledger-live-desktop": minor
3+
---
4+
5+
LLD - Fetch assets data on search

apps/ledger-live-desktop/src/newArch/features/ModularDrawer/ModularDrawerFlowManagerRemoteData.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,25 @@ const ModularDrawerFlowManagerRemoteData = ({
5151
});
5252

5353
const renderStepContent = (step: ModularDrawerStep) => {
54-
// TODO: We should find a better way to handle that. THe issue is that we always display AssetSelection screen
55-
// but in some cases we don't want to trigger analytics events as it may have been dismissed automatically depending on the flow.
56-
// For now we just return null if we are in ASSET_SELECTION step and there is only one currency.
57-
// This is a temporary solution until we find a better way to handle this but it works as we just don't render a skipped step.
5854
switch (step) {
5955
case MODULAR_DRAWER_STEP.ASSET_SELECTION:
60-
if (!hasOneCurrency) {
61-
return (
62-
<AssetSelection
63-
assetsToDisplay={assetsToDisplay}
64-
providersLoadingStatus={loadingStatus}
65-
originalAssetsToDisplay={originalAssetsToDisplay}
66-
sortedCryptoCurrencies={filteredSortedCryptoCurrencies}
67-
defaultSearchValue={searchedValue}
68-
assetsConfiguration={assetsConfiguration}
69-
currenciesByProvider={currenciesByProvider}
70-
setAssetsToDisplay={() => {}} // Not needed anymore with the search filtering done by the backend
71-
setSearchedValue={setSearchedValue}
72-
onAssetSelected={handleAssetSelected}
73-
flow={flow}
74-
source={source}
75-
/>
76-
);
77-
}
78-
return null;
56+
return (
57+
<AssetSelection
58+
assetsToDisplay={assetsToDisplay}
59+
providersLoadingStatus={loadingStatus}
60+
originalAssetsToDisplay={originalAssetsToDisplay}
61+
sortedCryptoCurrencies={filteredSortedCryptoCurrencies}
62+
defaultSearchValue={searchedValue}
63+
assetsConfiguration={assetsConfiguration}
64+
currenciesByProvider={currenciesByProvider}
65+
setAssetsToDisplay={() => {}} // Not needed anymore with the search filtering done by the backend
66+
setSearchedValue={setSearchedValue}
67+
onAssetSelected={handleAssetSelected}
68+
flow={flow}
69+
source={source}
70+
hasOneCurrency={hasOneCurrency}
71+
/>
72+
);
7973
case MODULAR_DRAWER_STEP.NETWORK_SELECTION:
8074
return (
8175
<NetworkSelection

apps/ledger-live-desktop/src/newArch/features/ModularDrawer/hooks/useModularDrawerFlowState.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
onAccountSelected?: (account: AccountLike, parentAccount?: Account) => void;
2727
hasOneCurrency: boolean;
2828
flow: string;
29+
searchedValue?: string;
2930
};
3031

3132
export function useModularDrawerFlowState({
@@ -39,6 +40,7 @@ export function useModularDrawerFlowState({
3940
onAccountSelected,
4041
hasOneCurrency,
4142
flow,
43+
searchedValue,
4244
}: Props) {
4345
const { trackModularDrawerEvent } = useModularDrawerAnalytics();
4446

@@ -179,7 +181,7 @@ export function useModularDrawerFlowState({
179181
};
180182

181183
useEffect(() => {
182-
if (hasOneCurrency && !selectedAsset) {
184+
if (hasOneCurrency && !selectedAsset && !searchedValue) {
183185
const currencyIdToFind = currenciesIdsArray[0];
184186
const currency = getTokenOrCryptoCurrencyById(currencyIdToFind);
185187

@@ -195,6 +197,7 @@ export function useModularDrawerFlowState({
195197
hasOneCurrency,
196198
selectedAsset,
197199
currenciesIdsArray,
200+
searchedValue,
198201
]);
199202

200203
return {

apps/ledger-live-desktop/src/newArch/features/ModularDrawer/hooks/useModularDrawerRemoteData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export function useModularDrawerRemoteData({
7171
onAccountSelected,
7272
flow,
7373
hasOneCurrency,
74+
searchedValue,
7475
});
7576

7677
const { handleBack } = useModularDrawerBackButton({

apps/ledger-live-desktop/src/newArch/features/ModularDrawer/screens/AssetSelection/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type AssetSelectionStepProps = {
2020
setAssetsToDisplay: (assets: CryptoOrTokenCurrency[]) => void;
2121
onAssetSelected: (asset: CryptoOrTokenCurrency) => void;
2222
setSearchedValue: (value: string | undefined) => void;
23+
hasOneCurrency?: boolean;
2324
};
2425

2526
const AssetSelection = ({
@@ -35,6 +36,7 @@ const AssetSelection = ({
3536
setAssetsToDisplay,
3637
onAssetSelected,
3738
setSearchedValue,
39+
hasOneCurrency,
3840
}: Readonly<AssetSelectionStepProps>) => {
3941
const [shouldScrollToTop, setShouldScrollToTop] = useState(false);
4042

@@ -52,13 +54,15 @@ const AssetSelection = ({
5254

5355
return (
5456
<>
55-
<TrackDrawerScreen
56-
page={MODULAR_DRAWER_PAGE_NAME.MODULAR_ASSET_SELECTION}
57-
source={source}
58-
flow={flow}
59-
assetsConfig={assetsConfiguration}
60-
formatAssetConfig
61-
/>
57+
{!hasOneCurrency && (
58+
<TrackDrawerScreen
59+
page={MODULAR_DRAWER_PAGE_NAME.MODULAR_ASSET_SELECTION}
60+
source={source}
61+
flow={flow}
62+
assetsConfig={assetsConfiguration}
63+
formatAssetConfig
64+
/>
65+
)}
6266
<SearchInputContainer
6367
setItemsToDisplay={setAssetsToDisplay}
6468
setSearchedValue={setSearchedValue}

0 commit comments

Comments
 (0)