-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🛣️ [FEAT]: Create the
/ledgersync
deeplink (#7706)
* Create LLDs /ledgersync deeplink * Use redux to show the ledger sync activation drawer * Create LLMs /ledgersync deeplink * Update change log --------- Co-authored-by: Theophile Sandoz <Theophile Sandoz>
- Loading branch information
Showing
12 changed files
with
91 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"ledger-live-desktop": minor | ||
"live-mobile": minor | ||
--- | ||
|
||
Create the `/ledgersync` deeplink |
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
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,7 +1,11 @@ | ||
import { createAction } from "redux-actions"; | ||
import { WalletSyncActionTypes } from "./types"; | ||
import type { WalletSyncSetManageKeyDrawerPayload } from "./types"; | ||
import type { WalletSyncSetActivateDrawer, WalletSyncSetManageKeyDrawerPayload } from "./types"; | ||
|
||
export const setWallectSyncManageKeyDrawer = createAction<WalletSyncSetManageKeyDrawerPayload>( | ||
WalletSyncActionTypes.WALLET_SYNC_SET_MANAGE_KEY_DRAWER, | ||
); | ||
|
||
export const setLedgerSyncActivateDrawer = createAction<WalletSyncSetActivateDrawer>( | ||
WalletSyncActionTypes.LEDGER_SYNC_SET_ACTIVATE_DRAWER, | ||
); |
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
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
27 changes: 27 additions & 0 deletions
27
.../ledger-live-mobile/src/newArch/features/WalletSync/screens/LedgerSyncDeepLinkHandler.tsx
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,27 @@ | ||
import { StackActions, useNavigation } from "@react-navigation/native"; | ||
import { useEffect } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { trustchainSelector } from "@ledgerhq/trustchain/store"; | ||
import { setLedgerSyncActivateDrawer } from "~/actions/walletSync"; | ||
import { NavigatorName, ScreenName } from "~/const"; | ||
|
||
export function LedgerSyncDeepLinkHandler() { | ||
const hasTrustchain = !!useSelector(trustchainSelector)?.rootId; | ||
const navigation = useNavigation(); | ||
const dispatch = useDispatch(); | ||
|
||
useEffect(() => { | ||
if (hasTrustchain) { | ||
const routeName = NavigatorName.WalletSync; | ||
const screen = ScreenName.WalletSyncActivated; | ||
navigation.dispatch(StackActions.replace(routeName, { screen })); | ||
} else { | ||
const routeName = NavigatorName.Settings; | ||
const screen = ScreenName.GeneralSettings; | ||
navigation.dispatch(StackActions.replace(routeName, { screen })); | ||
dispatch(setLedgerSyncActivateDrawer(true)); | ||
} | ||
}, [hasTrustchain, navigation, dispatch]); | ||
|
||
return null; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
import { handleActions } from "redux-actions"; | ||
import type { Action, ReducerMap } from "redux-actions"; | ||
import type { State, WalletSyncState } from "./types"; | ||
import { WalletSyncPayload, WalletSyncSetManageKeyDrawerPayload } from "../actions/types"; | ||
import { | ||
WalletSyncActionTypes, | ||
WalletSyncPayload, | ||
WalletSyncSetActivateDrawer, | ||
WalletSyncSetManageKeyDrawerPayload, | ||
} from "../actions/types"; | ||
|
||
export const INITIAL_STATE: WalletSyncState = { | ||
isManageKeyDrawerOpen: false, | ||
isActivateDrawerOpen: false, | ||
}; | ||
|
||
const handlers: ReducerMap<WalletSyncState, WalletSyncPayload> = { | ||
WALLET_SYNC_SET_MANAGE_KEY_DRAWER: (state, action) => ({ | ||
[WalletSyncActionTypes.WALLET_SYNC_SET_MANAGE_KEY_DRAWER]: (state, action) => ({ | ||
...state, | ||
isManageKeyDrawerOpen: (action as Action<WalletSyncSetManageKeyDrawerPayload>).payload, | ||
}), | ||
[WalletSyncActionTypes.LEDGER_SYNC_SET_ACTIVATE_DRAWER]: (state, action) => ({ | ||
...state, | ||
isActivateDrawerOpen: (action as Action<WalletSyncSetActivateDrawer>).payload, | ||
}), | ||
}; | ||
|
||
export const storeSelector = (state: State): WalletSyncState => state.walletSync; | ||
export const manageKeyDrawerSelector = (state: State): boolean => | ||
state.walletSync.isManageKeyDrawerOpen; | ||
export const activateDrawerSelector = (state: State): boolean => | ||
state.walletSync.isActivateDrawerOpen; | ||
|
||
export default handleActions<WalletSyncState, WalletSyncPayload>(handlers, INITIAL_STATE); |
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