Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

use another node link #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion app/screens/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { WALLET_MANAGER } from '../navigators/WalletManager'
import Pad from '../components/Pad'
import OnboardingInput from '../components/OnboardingInput'
import OnboardingBtn from '../components/OnboardingBtn'
import * as Navigation from '../services/navigation'
import { CONNECT_TO_NODE } from '../screens/ConnectToNode'

export const LOGIN = 'LOGIN'

Expand All @@ -45,6 +47,7 @@ const shockBG = require('../assets/images/shock-bg.png')
* @prop {string} err
* @prop {string} pass
* @prop {Wallet.WalletStatus|null} walletStatus Null when fetching.
* @prop {boolean} deletingNodeIP
*/

/**
Expand All @@ -67,6 +70,7 @@ export default class Login extends React.Component {
err: '',
pass: '',
walletStatus: null,
deletingNodeIP: false,
}

/** @type {React.RefObject<TextInput>} */
Expand Down Expand Up @@ -95,6 +99,7 @@ export default class Login extends React.Component {
this.setState({
cachedAlias: null,
fetchingCachedAlias: true,
deletingNodeIP: false,
})

const walletStatus = await Wallet.walletStatus()
Expand Down Expand Up @@ -230,6 +235,12 @@ export default class Login extends React.Component {
)
}

onPressChangeNode = async () => {
this.setState({ deletingNodeIP: true })
await Cache.writeNodeURLOrIP(null)
Navigation.navigate(CONNECT_TO_NODE)
}

render() {
const {
alias,
Expand All @@ -239,8 +250,13 @@ export default class Login extends React.Component {
fetchingCachedAlias,
pass,
walletStatus,
deletingNodeIP,
} = this.state
const loading = awaitingRes || fetchingCachedAlias || walletStatus === null
const loading =
awaitingRes ||
fetchingCachedAlias ||
walletStatus === null ||
deletingNodeIP
const enableUnlockBtn =
!loading && (alias.length > 0 || cachedAlias !== null) && pass.length > 0

Expand Down Expand Up @@ -293,6 +309,10 @@ export default class Login extends React.Component {
<Text onPress={this.onPressCreateNewAlias} style={linkTextStyle}>
Create new alias
</Text>
<Pad amount={ITEM_SPACING / 2} />
<Text onPress={this.onPressChangeNode} style={linkTextStyle}>
Use another node
</Text>
</OnboardingScreen>

<ShockDialog
Expand Down