Skip to content

Commit

Permalink
hotfix: changing pin and deleting all instead of only key (#355)
Browse files Browse the repository at this point in the history
* hotfix: changing pin and deleting all instead of only key

* hotfix: fix initial setting of PIN

- take user to home screen not back and remove timeout
- update core state of hasPin after save
- fix lint issue with saving data not returning promise.

Co-authored-by: Alexander Evchenko <[email protected]>
Co-authored-by: Jesse Clark <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2022
1 parent 9e32424 commit 96fc860
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/core/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export const Core = () => {
},
})

const handleUpdatePin = (newPin: string) => {
editPin(newPin)
setState({ ...state, hasPin: true })
}

if (state.hasKeys && state.hasPin && !unlocked) {
return (
<RequestPIN unlock={onScreenUnlock} resetKeysAndPin={resetKeysAndPin} />
Expand Down Expand Up @@ -156,7 +161,7 @@ export const Core = () => {
}),
}}
createPin={createPin}
editPin={editPin}
editPin={handleUpdatePin}
setWalletIsDeployed={setWalletIsDeployed}
balancesScreenProps={{ fetcher: rifWalletServicesFetcher }}
sendScreenProps={{ rnsResolver }}
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/rootNavigator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface Props {
rifWalletServicesSocket: IRifWalletServicesSocket
keyManagementProps: CreateKeysProps
createPin: (newPin: string) => Promise<void>
editPin: (newPin: string) => Promise<void>
editPin: (newPin: string) => void
setWalletIsDeployed: (address: string, value?: boolean) => void
balancesScreenProps: Screens.BalancesScreenProps
activityScreenProps: Screens.ActivityScreenProps
Expand Down
17 changes: 7 additions & 10 deletions src/screens/changePin/ChangePinScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, { useState, useRef } from 'react'
import { PinManager } from '../../components/PinManager'
import { RootStackScreenProps } from 'navigation/rootNavigator/types'
import {
rootStackRouteNames,
RootStackScreenProps,
} from 'navigation/rootNavigator/types'
import { TouchableOpacity, View, StyleSheet } from 'react-native'
import { Arrow } from '../../components/icons'
import { MediumText } from '../../components'
Expand All @@ -18,21 +21,15 @@ const ChangePinScreen: React.FC<
confirmPin: '',
})
const isSubmitting = useRef(false)
const [confirmPinTitle, setConfirmPinTitle] = useState('Confirm new PIN')
const [pinError, setPinError] = useState('')
const [resetPin, setResetPin] = useState(0)

const onPinSubmit = () => {
if (!isSubmitting.current) {
isSubmitting.current = true
try {
editPin(pinSteps.current.pin).then(() => {
setConfirmPinTitle('PIN confirmed')

setTimeout(() => {
navigation.goBack()
}, 2500)
})
editPin(pinSteps.current.pin)
navigation.navigate(rootStackRouteNames.Home)
} catch (error) {
setPinError(
'An error occurred while saving the new PIN. Please try again.',
Expand Down Expand Up @@ -80,7 +77,7 @@ const ChangePinScreen: React.FC<
<View style={styles.pinView}>
<PinManager
key={resetPin}
title={confirmPinTitle}
title="Confirm new PIN"
handleSubmit={onPinChange(2)}
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export {
} from './accounts/AccountsScreen'
export { ProfileCreateScreen } from './profile/ProfileCreateScreen'
export { ProfileDetailsScreen } from './profile/ProfileDetailsScreen'
export { default as BitcoinReceiveScreen } from './receive/BitcoinReceiveScreen'
export { BitcoinReceiveScreen } from './receive/BitcoinReceiveScreen'
export { FeedbackScreen } from './feedback/FeedbackScreen'
4 changes: 1 addition & 3 deletions src/screens/receive/BitcoinReceiveScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getDomains } from '../../storage/DomainsStore'
import { ReceiveScreen } from './ReceiveScreen'
import { shortAddress } from '../../lib/utils'

const BitcoinReceiveScreen: React.FC<any> = ({
export const BitcoinReceiveScreen: React.FC<any> = ({
route: {
params: { network },
},
Expand Down Expand Up @@ -40,5 +40,3 @@ const BitcoinReceiveScreen: React.FC<any> = ({
<Loading />
)
}

export default BitcoinReceiveScreen
2 changes: 1 addition & 1 deletion src/storage/MainStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const hasKeys = () => MainStorage.has(keyManagement)
export const getKeys = () => MainStorage.get(keyManagement)
export const saveKeys = (keysValue: string) =>
MainStorage.set(keyManagement, keysValue)
export const deleteKeys = MainStorage.deleteAll
export const deleteKeys = () => MainStorage.delete(keyManagement)

// keyVerificationReminder functions
export const hasKeyVerificationReminder = () =>
Expand Down

0 comments on commit 96fc860

Please sign in to comment.