Skip to content

Commit

Permalink
Merge pull request #825 from alephium/add-catch
Browse files Browse the repository at this point in the history
Add try/catch
  • Loading branch information
nop33 authored Sep 9, 2024
2 parents 3714cbe + 7d33042 commit 64c00ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/mobile-wallet/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"Created fund password": "Created fund password",
"Delete fund password": "Delete fund password",
"Fund password was deleted.": "Fund password was deleted.",
"Could not save fund password.": "Could not save fund password.",
"You can set a new password below. This password will be required for critical operations involving the safety of your funds and cannot be recovered.": "You can set a new password below. This password will be required for critical operations involving the safety of your funds and cannot be recovered.",
"The fund password acts as an additional authentication layer for critical operations involving the safety of your funds such as revealing your secret recovery phrase or sending funds.": "The fund password acts as an additional authentication layer for critical operations involving the safety of your funds such as revealing your secret recovery phrase or sending funds.",
"Edit password": "Edit password",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import useFundPasswordGuard from '~/features/fund-password/useFundPasswordGuard'
import { useAppDispatch } from '~/hooks/redux'
import usePassword from '~/hooks/usePassword'
import RootStackParamList from '~/navigation/rootStackRoutes'
import { showToast } from '~/utils/layout'
import { showExceptionToast, showToast } from '~/utils/layout'
import { resetNavigation } from '~/utils/navigation'

interface FundPasswordScreenProps
Expand Down Expand Up @@ -80,20 +80,24 @@ const FundPasswordScreen = ({ navigation, ...props }: FundPasswordScreenProps) =
}, [currentFundPassword])

const handleSavePress = async () => {
await storeFundPassword(newPassword || password)
dispatch(fundPasswordUseToggled(true))
showToast({
text1: t('Saved!'),
text2: newPassword ? t('Fund password was updated.') : t('Fund password was set up.'),
type: 'success'
})
cameFromBackupScreen ? resetNavigation(navigation) : navigation.goBack()
sendAnalytics({
event: newPassword ? t('Updated fund password') : t('Created fund password'),
props: {
origin: props.route.params.origin
}
})
try {
await storeFundPassword(newPassword || password)
dispatch(fundPasswordUseToggled(true))
showToast({
text1: t('Saved!'),
text2: newPassword ? t('Fund password was updated.') : t('Fund password was set up.'),
type: 'success'
})
cameFromBackupScreen ? resetNavigation(navigation) : navigation.goBack()
sendAnalytics({
event: newPassword ? t('Updated fund password') : t('Created fund password'),
props: {
origin: props.route.params.origin
}
})
} catch (error) {
showExceptionToast(error, t('Could not save fund password.'))
}
}

const handlePasswordEdit = () => {
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile-wallet/src/persistent-storage/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export const validateAndRepareStoredWalletData = async (
onPress: async () => {
try {
await generateAndStoreWalletMetadata('My wallet', false)
} catch (error) {
console.error(error)
} finally {
walletMetadata = await getWalletMetadata(false)
}
Expand Down

0 comments on commit 64c00ea

Please sign in to comment.