Skip to content

Commit

Permalink
guard if statedb empty (#8332)
Browse files Browse the repository at this point in the history
* guard if statedb empty

* update market-page-search snapshot
  • Loading branch information
Wozacosta committed Nov 8, 2024
1 parent d36a780 commit 299441f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/smart-items-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"live-mobile": patch
"@ledgerhq/live-common": patch
---

fix: better logic and guard against accessing null db
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 10 additions & 11 deletions apps/ledger-live-mobile/src/components/Web3AppWebview/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,16 @@ export function useWebView(
}, []);

useEffect(() => {
const latestCacheBustedId = getLatest(manifest.id);
const init = getLatest("init");
// checking for init, which is set in INITIAL_PLATFORM_STATE
// makes sure we're not just getting the default value, undefined
if (
webviewRef.current &&
init &&
manifest.cacheBustingId !== undefined &&
manifest.cacheBustingId > (latestCacheBustedId || 0)
) {
if (webviewRef.current.clearCache) {
if (webviewRef && webviewRef.current && manifest.cacheBustingId !== undefined) {
const latestCacheBustedId = getLatest(manifest.id);
const init = getLatest("init");
// checking for init, which is set in INITIAL_PLATFORM_STATE
// makes sure we're not just getting the default value, undefined
if (
init &&
manifest.cacheBustingId > (latestCacheBustedId || 0) &&
webviewRef.current.clearCache
) {
// save the latest cacheBustedId to the DiscoverDB
// to avoid clearingCache everytime this liveApp is loaded
edit(manifest.id, manifest.cacheBustingId);
Expand Down
2 changes: 1 addition & 1 deletion libs/ledger-live-common/src/wallet-api/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ function calculateTimeDiff(usedAt: string) {
export function useCacheBustedLiveApps([cacheBustedLiveAppsDb, setState]: CacheBustedLiveAppsdDB) {
const getLatest = useCallback(
(manifestId: string) => {
return cacheBustedLiveAppsDb[manifestId];
return cacheBustedLiveAppsDb?.[manifestId];
},
[cacheBustedLiveAppsDb],
);
Expand Down

0 comments on commit 299441f

Please sign in to comment.