Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CN-476): add category param filter to llm platform discover section #7580

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 4 additions & 2 deletions libs/ledger-live-common/src/wallet-api/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,10 @@ export interface Categories {
reset: () => void;
}

export function useCategories(manifests): Categories {
const [selected, setSelected] = useState(DISCOVER_INITIAL_CATEGORY);
export type CategoryId = Categories["selected"];

export function useCategories(manifests, initialCategory?: CategoryId | null): Categories {
const [selected, setSelected] = useState(initialCategory || DISCOVER_INITIAL_CATEGORY);

const reset = useCallback(() => {
setSelected(DISCOVER_INITIAL_CATEGORY);
Expand Down
Loading