-
Notifications
You must be signed in to change notification settings - Fork 327
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 #5547 from LedgerHQ/feat/LIVE-9823/LLDPostOnboardi…
…ngItems feat(LLD) Post Onboarding New Items
- Loading branch information
Showing
9 changed files
with
151 additions
and
50 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 @@ | ||
--- | ||
"@ledgerhq/types-live": patch | ||
"ledger-live-desktop": patch | ||
--- | ||
|
||
Adding new items to LLD post onboarding |
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
117 changes: 76 additions & 41 deletions
117
apps/ledger-live-desktop/src/renderer/modals/Receive/index.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 |
---|---|---|
@@ -1,61 +1,96 @@ | ||
import React, { PureComponent } from "react"; | ||
import React, { useState, useCallback, useEffect } from "react"; | ||
import logger from "~/renderer/logger"; | ||
import Modal from "~/renderer/components/Modal"; | ||
import Body, { StepId } from "./Body"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { accountsSelector } from "~/renderer/reducers/accounts"; | ||
import { openModal, closeModal } from "~/renderer/actions/modals"; | ||
|
||
type State = { | ||
stepId: StepId; | ||
isAddressVerified: boolean | undefined | null; | ||
verifyAddressError: Error | undefined | null; | ||
}; | ||
|
||
const INITIAL_STATE = { | ||
stepId: "account" as StepId, | ||
isAddressVerified: null, | ||
verifyAddressError: null, | ||
}; | ||
class ReceiveModal extends PureComponent<{}, State> { | ||
state = INITIAL_STATE; | ||
handleReset = () => | ||
this.setState({ | ||
...INITIAL_STATE, | ||
}); | ||
|
||
handleStepChange = (stepId: StepId) => | ||
this.setState({ | ||
stepId, | ||
}); | ||
|
||
handleChangeAddressVerified = (isAddressVerified?: boolean | null, err?: Error | null) => { | ||
const ReceiveModal = () => { | ||
const [state, setState] = useState<State>(INITIAL_STATE); | ||
|
||
const { stepId, isAddressVerified, verifyAddressError } = state; | ||
|
||
const setStepId = (newStepId: State["stepId"]) => { | ||
setState(prevState => ({ ...prevState, stepId: newStepId })); | ||
}; | ||
|
||
const setIsAddressVerified = (newIsAddressVerified: State["isAddressVerified"]) => { | ||
setState(prevState => ({ ...prevState, isAddressVerified: newIsAddressVerified })); | ||
}; | ||
|
||
const setVerifyAddressError = (newVerifyAddressError: State["verifyAddressError"]) => { | ||
setState(prevState => ({ ...prevState, verifyAddressError: newVerifyAddressError })); | ||
}; | ||
|
||
const handleReset = () => { | ||
setStepId(INITIAL_STATE.stepId); | ||
setIsAddressVerified(INITIAL_STATE.isAddressVerified); | ||
setVerifyAddressError(INITIAL_STATE.verifyAddressError); | ||
}; | ||
|
||
const handleChangeAddressVerified = (isAddressVerified?: boolean | null, err?: Error | null) => { | ||
if (err && err.name !== "UserRefusedAddress") { | ||
logger.critical(err); | ||
} | ||
this.setState({ | ||
isAddressVerified, | ||
verifyAddressError: err, | ||
}); | ||
setIsAddressVerified(isAddressVerified); | ||
setVerifyAddressError(err); | ||
}; | ||
|
||
render() { | ||
const { stepId, isAddressVerified, verifyAddressError } = this.state; | ||
const isModalLocked = stepId === "receive" && isAddressVerified === null; | ||
return ( | ||
<Modal | ||
name="MODAL_RECEIVE" | ||
centered | ||
onHide={this.handleReset} | ||
preventBackdropClick={isModalLocked} | ||
render={({ data, onClose }) => ( | ||
<Body | ||
onClose={onClose} | ||
stepId={stepId} | ||
isAddressVerified={isAddressVerified} | ||
verifyAddressError={verifyAddressError} | ||
onChangeAddressVerified={this.handleChangeAddressVerified} | ||
onChangeStepId={this.handleStepChange} | ||
params={data || {}} | ||
/> | ||
)} | ||
/> | ||
// Making sure at least one account exists, if not, redirecting to the add account modal | ||
const accounts = useSelector(accountsSelector); | ||
|
||
const dispatch = useDispatch(); | ||
const hasAccounts = !!accounts.length; | ||
|
||
const openAddAccounts = useCallback(() => { | ||
dispatch(closeModal("MODAL_RECEIVE")); | ||
dispatch( | ||
openModal("MODAL_ADD_ACCOUNTS", { | ||
currency: null, | ||
}), | ||
); | ||
} | ||
} | ||
}, [dispatch]); | ||
|
||
useEffect(() => { | ||
if (!hasAccounts) { | ||
openAddAccounts(); | ||
} | ||
}, [hasAccounts, openAddAccounts]); | ||
|
||
if (!hasAccounts) return null; | ||
|
||
const isModalLocked = stepId === "receive" && isAddressVerified === null; | ||
return ( | ||
<Modal | ||
name="MODAL_RECEIVE" | ||
centered | ||
onHide={handleReset} | ||
preventBackdropClick={isModalLocked} | ||
render={({ data, onClose }) => ( | ||
<Body | ||
onClose={onClose} | ||
stepId={stepId} | ||
isAddressVerified={isAddressVerified} | ||
verifyAddressError={verifyAddressError} | ||
onChangeAddressVerified={handleChangeAddressVerified} | ||
onChangeStepId={setStepId} | ||
params={data || {}} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ReceiveModal; |
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
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
57d63f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web-tools – ./apps/web-tools
web-tools-ledgerhq.vercel.app
live.ledger.tools
ledger-live-tools.vercel.app
ledger-live.vercel.app
web-tools-git-develop-ledgerhq.vercel.app
57d63f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Evm on Staging ($0.00) ⏲ 35.9s
6 critical spec errors
Spec Avalanche C-Chain failed!
Spec Binance Smart Chain failed!
Spec Ethereum failed!
Spec Ethereum Classic failed!
Spec Polygon failed!
Spec Ethereum Goerli failed!
Details of the 0 mutations
Spec Avalanche C-Chain (failed)
Spec Binance Smart Chain (failed)
Spec Ethereum (failed)
Spec Ethereum Classic (failed)
Spec Polygon (failed)
Spec Ethereum Goerli (failed)
Details of the 16 uncovered mutations
Spec Avalanche C-Chain (2)
Spec Binance Smart Chain (3)
Spec Ethereum (3)
Spec Ethereum Classic (2)
Spec Polygon (3)
Spec Ethereum Goerli (3)
Portfolio ($0.00) – Details of the 6 currencies
Performance ⏲ 35.9s
Time spent for each spec: (total across mutations)
57d63f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Bitcoin on Staging ($0.00) ⏲ 2min 51s
17 critical spec errors
Spec Bitcoin failed!
Spec Bitcoin Testnet failed!
Spec Bitcoin Cash failed!
Spec Bitcoin Gold failed!
Spec Dash failed!
Spec Digibyte failed!
Spec DogeCoin failed!
Spec Komodo failed!
Spec Litecoin failed!
Spec Peercoin failed!
Spec PivX failed!
Spec Qtum failed!
Spec Vertcoin failed!
Spec Viacoin failed!
Spec ZCash failed!
Spec Horizen failed!
Spec Decred failed!
Details of the 0 mutations
Spec Bitcoin (failed)
Spec Bitcoin Testnet (failed)
Spec Bitcoin Cash (failed)
Spec Bitcoin Gold (failed)
Spec Dash (failed)
Spec Digibyte (failed)
Spec DogeCoin (failed)
Spec Komodo (failed)
Spec Litecoin (failed)
Spec Peercoin (failed)
Spec PivX (failed)
Spec Qtum (failed)
Spec Vertcoin (failed)
Spec Viacoin (failed)
Spec ZCash (failed)
Spec Horizen (failed)
Spec Decred (failed)
Details of the 85 uncovered mutations
Spec Bitcoin (5)
Spec Bitcoin Testnet (5)
Spec Bitcoin Cash (5)
Spec Bitcoin Gold (5)
Spec Dash (5)
Spec Digibyte (5)
Spec DogeCoin (5)
Spec Komodo (5)
Spec Litecoin (5)
Spec Peercoin (5)
Spec PivX (5)
Spec Qtum (5)
Spec Vertcoin (5)
Spec Viacoin (5)
Spec ZCash (5)
Spec Horizen (5)
Spec Decred (5)
Portfolio ($0.00) – Details of the 17 currencies
Performance ⏲ 2min 51s
Time spent for each spec: (total across mutations)