Skip to content

Commit

Permalink
Merge pull request #6843 from LedgerHQ/bugfix/LIVE-12542-fix-manifest…
Browse files Browse the repository at this point in the history
…-loading

fix manifest loading breaking if no cache
  • Loading branch information
Wozacosta committed May 13, 2024
2 parents f19960f + 61326de commit 6885312
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/eight-cameras-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
"@ledgerhq/live-common": patch
---

fix manifest loading breaking if no cache
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,5 @@ export function PlatformAppProviderWrapper({ children }: PlatformAppProviderWrap
}

function useLocalLiveAppDB() {
return useDB(
"app",
DISCOVER_STORE_KEY,
INITIAL_PLATFORM_STATE,
state => state.localLiveApp || INITIAL_PLATFORM_STATE.localLiveApp,
);
return useDB("app", DISCOVER_STORE_KEY, INITIAL_PLATFORM_STATE, state => state.localLiveApp);
}
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/PlatformAppProviderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ function useLocalLiveAppDB() {
return useDB<DiscoverDB, DiscoverDB["localLiveApp"]>(
DISCOVER_STORE_KEY,
INITIAL_PLATFORM_STATE,
state => state.localLiveApp || INITIAL_PLATFORM_STATE.localLiveApp,
state => state.localLiveApp,
);
}
16 changes: 14 additions & 2 deletions libs/ledger-live-common/src/wallet-api/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ import openTransportAsSubject, { BidirectionalEvent } from "../hw/openTransportA
import { AppResult } from "../hw/actions/app";
import { UserRefusedOnDevice } from "@ledgerhq/errors";
import { Transaction } from "../generated/types";
import { DISCOVER_INITIAL_CATEGORY, MAX_RECENTLY_USED_LENGTH } from "./constants";
import {
DISCOVER_INITIAL_CATEGORY,
INITIAL_PLATFORM_STATE,
MAX_RECENTLY_USED_LENGTH,
} from "./constants";
import { DiscoverDB } from "./types";
import { LiveAppManifest } from "../platform/types";
import { WalletState } from "@ledgerhq/live-wallet/store";
Expand Down Expand Up @@ -858,10 +862,18 @@ export interface LocalLiveApp {
}

export function useLocalLiveApp([LocalLiveAppDb, setState]: LocalLiveAppDB): LocalLiveApp {
useEffect(() => {
if (LocalLiveAppDb === undefined) {
setState(discoverDB => {
return { ...discoverDB, localLiveApp: INITIAL_PLATFORM_STATE.localLiveApp };
});
}
}, [LocalLiveAppDb, setState]);

const addLocalManifest = useCallback(
(newLocalManifest: LiveAppManifest) => {
setState(discoverDB => {
const newLocalLiveAppList = discoverDB.localLiveApp.filter(
const newLocalLiveAppList = discoverDB.localLiveApp?.filter(
manifest => manifest.id !== newLocalManifest.id,
);

Expand Down

0 comments on commit 6885312

Please sign in to comment.