-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8069 from LedgerHQ/feat/LIVE-14442
feat(web3Hub): fix state management with jotai
- Loading branch information
Showing
6 changed files
with
39 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 2 additions & 9 deletions
11
apps/ledger-live-mobile/src/newArch/features/Web3Hub/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
import type { Web3HubDB } from "./types"; | ||
|
||
export const URL_ORIGIN = "https://live-app-catalog.ledger.com"; | ||
|
||
export const WEB3HUB_STORE_KEY = "web3hub"; | ||
|
||
export const INITIAL_WEB3HUB_STATE: Web3HubDB = { | ||
recentlyUsed: [], | ||
dismissedManifests: {}, | ||
// localLiveApp: [], | ||
}; | ||
export const RECENTLY_USED_KEY = "WEB3HUB_RECENTLY_USED"; | ||
export const DISSMISSED_MANIFETS_KEY = "WEB3HUB_DISSMISSED_MANIFETS"; |
15 changes: 15 additions & 0 deletions
15
apps/ledger-live-mobile/src/newArch/features/Web3Hub/db.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
import { Web3HubDB } from "LLM/features/Web3Hub/types"; | ||
import { atomWithStorage, createJSONStorage } from "jotai/utils"; | ||
import { DISSMISSED_MANIFETS_KEY, RECENTLY_USED_KEY } from "./constants"; | ||
|
||
const emptyRecentlyUsed: Web3HubDB["recentlyUsed"] = []; | ||
export const recentlyUseAtom = storedAtom(RECENTLY_USED_KEY, emptyRecentlyUsed); | ||
|
||
const emptyDismissedManifests: Web3HubDB["dismissedManifests"] = {}; | ||
export const dismissedManifestsAtom = storedAtom(DISSMISSED_MANIFETS_KEY, emptyDismissedManifests); | ||
|
||
export function storedAtom<T = unknown>(key: string, defaultValue: T) { | ||
const storage = createJSONStorage<T>(() => AsyncStorage); | ||
return atomWithStorage<T>(key, defaultValue, storage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.