Skip to content

Commit

Permalink
Merge pull request #7580 from LedgerHQ/CN-476-add-category-param-filt…
Browse files Browse the repository at this point in the history
…er-to-llm-platform-discover-section

feat(CN-476): add category param filter to llm platform discover section
  • Loading branch information
marcotoniut-ledger committed Aug 14, 2024
2 parents f895f64 + e0c13b4 commit 63e4fdc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/soft-kings-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"live-mobile": minor
"@ledgerhq/live-common": minor
---

Add discover section deep link initial category filter to enable links like `ledgerlive://discover?category=restaking` to load the discover screen with the category pre-selected
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ import { RecentlyUsed } from "./RecentlyUsed";
import { CatalogSection } from "./CatalogSection";
import { DAppDisclaimer } from "./DAppDisclaimer";
import { LocalLiveApp } from "./LocalLiveApp";
import { useRoute } from "@react-navigation/native";

const AnimatedView = Animatable.View;

export function Catalog() {
const { t } = useTranslation();
const title = t("browseWeb3.catalog.title");
const { categories, recentlyUsed, search, disclaimer, localLiveApps } = useCatalog();

const { params } = useRoute();

const deeplinkInitialCategory =
params && "category" in params && typeof params.category === "string" ? params.category : null;

const { categories, recentlyUsed, search, disclaimer, localLiveApps } =
useCatalog(deeplinkInitialCategory);

return (
<TabBarSafeAreaView edges={["top", "bottom", "left", "right"]}>
{/* TODO: put under the animation header and style */}
Expand Down
5 changes: 3 additions & 2 deletions apps/ledger-live-mobile/src/screens/Platform/v2/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useDisclaimerRaw,
useRecentlyUsed,
DisclaimerRaw,
Categories,
} from "@ledgerhq/live-common/wallet-api/react";
import { useLocalLiveAppContext } from "@ledgerhq/live-common/wallet-api/LocalLiveAppProvider/index";

Expand All @@ -25,13 +26,13 @@ import { readOnlyModeEnabledSelector } from "../../../reducers/settings";
import { NavigationProps } from "./types";
import { useManifests } from "@ledgerhq/live-common/platform/providers/RemoteLiveAppProvider/index";

export function useCatalog() {
export function useCatalog(initialCategory?: Categories["selected"] | null) {
const recentlyUsedDB = useRecentlyUsedDB();
const { state: localLiveApps } = useLocalLiveAppContext();
const allManifests = useManifests();
const completeManifests = useManifests({ visibility: ["complete"] });
const combinedManifests = useManifests({ visibility: ["searchable", "complete"] });
const categories = useCategories(completeManifests);
const categories = useCategories(completeManifests, initialCategory);
const recentlyUsed = useRecentlyUsed(combinedManifests, recentlyUsedDB);

const search = useSearch<AppManifest, TextInput>({
Expand Down

0 comments on commit 63e4fdc

Please sign in to comment.