Improve error handling

This commit is contained in:
minibits-cash
2025-06-16 11:43:28 +02:00
parent fd8df2b5dd
commit ecb4931215
5 changed files with 10 additions and 21 deletions
+3 -3
View File
@@ -97,12 +97,12 @@ export const WalletProfileStoreModel = types
hydrate: flow(function* hydrate(profileRecord: WalletProfileRecord) {
const {name, nip05, lud16, avatar, pubkey, walletId} = profileRecord
self.pubkey = pubkey
self.walletId = walletId
self.name = name // default name is set on server side, equals walletId
self.nip05 = nip05 // default is name@minibits.cash set on server side
self.lud16 = lud16 // equals to nip05 for all @minibits.cash addresses, set on server side
self.picture = avatar // default picture is set on server side
self.pubkey = pubkey
self.walletId = walletId
yield self.publishToRelays()
})
@@ -123,7 +123,7 @@ export const WalletProfileStoreModel = types
return self
} catch (e: any) {
// Unlikely we might hit the same walletId so we retry with another one
if(e.name === Err.ALREADY_EXISTS_ERROR) {
if(e.name.includes(Err.ALREADY_EXISTS_ERROR)) {
// recreate walletId + default name
const name = getRandomUsername()
// attempt to create new unique profile again
+1 -1
View File
@@ -135,7 +135,7 @@ export const ImportBackupScreen = observer(function ImportBackupScreen({ route }
}
} catch (e: any) {
// Profile with provided seed hash does not exists
if(e.name === Err.NOTFOUND_ERROR) {
if(e.name.includes(Err.NOTFOUND_ERROR)) {
setIsNewProfileNeeded(true)
} else {
handleError(e)
+2 -15
View File
@@ -32,27 +32,14 @@ export const NwcScreen = observer(function NwcScreen(_props) {
const [info, setInfo] = useState('')
const [error, setError] = useState<AppError | undefined>()
const [isLoading, setIsLoading] = useState(false)
const [isRemoteDataPushEnabled, setIsRemoteDataPushEnabled] = useState<boolean>(false)
const [isRemoteDataPushEnabled, setIsRemoteDataPushEnabled] = useState<boolean>(walletProfileStore.device ? true : false)
useHeader({
leftIcon: 'faArrowLeft',
onLeftPress: () => navigation.goBack(),
rightIcon: isRemoteDataPushEnabled ? 'faRotate' : undefined,
onRightPress: () => isRemoteDataPushEnabled ? onConnect() : false
})
useEffect(() => {
const getNotificationPermission = async () => {
try {
const remoteEnabled = walletProfileStore.device ? true : false
setIsRemoteDataPushEnabled(remoteEnabled)
} catch (e: any) {
log.warn(e.name, e.message)
return false // silent
}
}
getNotificationPermission()
}, [])
})
useEffect(() => {
+1 -1
View File
@@ -168,7 +168,7 @@ export const SeedRecoveryScreen = observer(function SeedRecoveryScreen({ route }
}
} catch (e: any) {
// Profile with provided seed hash does not exists
if(e.name === Err.NOTFOUND_ERROR) {
if(e.name.includes(Err.NOTFOUND_ERROR)) {
setIsNewProfileNeeded(true)
} else {
handleError(e)
+3 -1
View File
@@ -86,7 +86,8 @@ export const WelcomeScreen = function ({ route }: Props) {
const {
userSettingsStore,
relaysStore,
walletProfileStore,
walletProfileStore,
walletStore,
mintsStore
} = useStores()
@@ -121,6 +122,7 @@ export const WelcomeScreen = function ({ route }: Props) {
// save keys after successful profile creation
await KeyChain.saveWalletKeys(keys)
walletStore.cleanCachedWalletKeys()
}
if(!mintsStore.mintExists(MINIBITS_MINT_URL)) {