From 176156fc9d40332afcdba883bdcdcf8abc4063b7 Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Sun, 1 Jun 2025 23:32:31 +0200 Subject: [PATCH] Show receiver icon in transaction list, if it is known. Small UI fixes. --- .../xcschemes/minibits_wallet.xcscheme | 2 +- package.json | 2 +- src/components/BottomModal.tsx | 10 ++++----- src/components/Loading.tsx | 4 ++-- src/models/ContactsStore.ts | 4 ++++ src/models/WalletStore.ts | 22 +++++++++++++------ .../Transactions/TransactionListItem.tsx | 9 ++++++++ src/screens/TransferScreen.tsx | 21 ++++++++++++++---- src/screens/WalletScreen.tsx | 2 +- src/services/walletService.ts | 2 +- 10 files changed, 56 insertions(+), 22 deletions(-) diff --git a/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme b/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme index 9a1b755..72677cb 100644 --- a/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme +++ b/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme @@ -31,7 +31,7 @@ shouldAutocreateTestPlan = "YES"> - + {/**/} {HeadingComponent || (isHeadingPresent && ( - + {/**/} {props.statusMessage && ()} diff --git a/src/models/ContactsStore.ts b/src/models/ContactsStore.ts index 7571006..859d250 100644 --- a/src/models/ContactsStore.ts +++ b/src/models/ContactsStore.ts @@ -37,6 +37,10 @@ import { MINIBITS_NIP05_DOMAIN } from '@env' const c = self.contacts.find(c => c.npub === npub) return c ? c : undefined }, + findByLud16: (lud16: string) => { + const c = self.contacts.find(c => c.lud16 === lud16) + return c ? c : undefined + }, alreadyExists(pubkey: string) { return self.contacts.some(m => m.pubkey === pubkey) ? true : false }, diff --git a/src/models/WalletStore.ts b/src/models/WalletStore.ts index e47ccbe..0bc6f78 100644 --- a/src/models/WalletStore.ts +++ b/src/models/WalletStore.ts @@ -470,7 +470,9 @@ export const WalletStoreModel = types return {proofs, swapFeePaid} } catch (e: any) { - if(!e.message.toLowerCase().includes('timeout')) { + if(!e.message.toLowerCase().includes('timeout') && + !e.message.toLowerCase().includes('network request failed')) { + // remove in-flight request only if it was not a timeout or network error currentCounter.removeInFlightRequest(transactionId) } throw new AppError( @@ -555,9 +557,11 @@ export const WalletStoreModel = types } } catch (e: any) { - if(!e.message.toLowerCase().includes('timeout')) { - currentCounter.removeInFlightRequest(transactionId) - } + if(!e.message.toLowerCase().includes('timeout') && + !e.message.toLowerCase().includes('network request failed')) { + // remove in-flight request only if it was not a timeout or network error + currentCounter.removeInFlightRequest(transactionId) + } let message = 'Swap to prepare ecash to send has failed.' if (isOnionMint(mintUrl)) message += TorVPNSetupInstructions; @@ -732,9 +736,11 @@ export const WalletStoreModel = types return proofs } catch (e: any) { - if(!e.message.toLowerCase().includes('timeout')) { + if(!e.message.toLowerCase().includes('timeout') && + !e.message.toLowerCase().includes('network request failed')) { + // remove in-flight request only if it was not a timeout or network error currentCounter.removeInFlightRequest(transactionId) - } + } let message = 'Error on request to mint new ecash.' if (isOnionMint(mintUrl)) message += TorVPNSetupInstructions; @@ -841,7 +847,9 @@ export const WalletStoreModel = types return meltResponse } catch (e: any) { - if(!e.message.toLowerCase().includes('timeout')) { + if(!e.message.toLowerCase().includes('timeout') && + !e.message.toLowerCase().includes('network request failed')) { + // remove in-flight request only if it was not a timeout or network error currentCounter.removeInFlightRequest(transactionId) } diff --git a/src/screens/Transactions/TransactionListItem.tsx b/src/screens/Transactions/TransactionListItem.tsx index bf5e9d0..8a15724 100644 --- a/src/screens/Transactions/TransactionListItem.tsx +++ b/src/screens/Transactions/TransactionListItem.tsx @@ -169,6 +169,15 @@ export const TransactionListItem = observer(function (props: TransactionListProp return () } + if([TransactionType.SEND, TransactionType.TRANSFER].includes(tx.type)) { + if(tx.profile) { + const profilePicture = getProfilePicture(tx.profile) + if(profilePicture) { + return profilePicture + } + } + } + return () } diff --git a/src/screens/TransferScreen.tsx b/src/screens/TransferScreen.tsx index 377ae85..f684e2b 100644 --- a/src/screens/TransferScreen.tsx +++ b/src/screens/TransferScreen.tsx @@ -69,7 +69,7 @@ export const TransferScreen = observer(function TransferScreen({ route }: Props) const amountInputRef = useRef(null) const lnurlCommentInputRef = useRef(null) - const {proofsStore, mintsStore, paymentRequestsStore, walletStore, walletProfileStore} = useStores() + const {proofsStore, mintsStore, paymentRequestsStore, walletStore, walletProfileStore, contactsStore} = useStores() // const {walletStore} = nonPersistedStores const isInternetReachable = useIsInternetReachable() @@ -377,9 +377,15 @@ useEffect(() => { setTransaction(transaction) if(transaction && lnurlPayParams && lnurlPayParams.address) { - transaction.setSentTo( - lnurlPayParams.address as string - ) + + const profile = contactsStore.findByLud16(lnurlPayParams.address) + + if (profile) { + transaction.setSentTo(profile.nip05 || profile.name) + transaction.setProfile(JSON.stringify(profile)) + } else { + transaction.setSentTo(lnurlPayParams.address) + } } if (error) { // This handles timed out pending payments @@ -583,12 +589,19 @@ const onEncodedInvoice = async function (encoded: string, paymentRequestDesc: st log.trace("[onEncodedInvoice] start", {mintUrl, unit}) try { + //@ts-ignore navigation.setParams({encodedInvoice: undefined}) + //@ts-ignore navigation.setParams({paymentRequest: undefined}) + //@ts-ignore navigation.setParams({lnurlParams: undefined}) + //@ts-ignore navigation.setParams({paymentOption: undefined}) + //@ts-ignore navigation.setParams({fixedAmount: undefined}) + //@ts-ignore navigation.setParams({isDonation: undefined}) + //@ts-ignore navigation.setParams({donationForName: undefined}) const invoice = LightningUtils.decodeInvoice(encoded) diff --git a/src/screens/WalletScreen.tsx b/src/screens/WalletScreen.tsx index 99f0940..8bf2f60 100644 --- a/src/screens/WalletScreen.tsx +++ b/src/screens/WalletScreen.tsx @@ -1085,7 +1085,7 @@ const $screen: ViewStyle = { const $headerContainer: TextStyle = { alignItems: 'center', // padding: spacing.tiny, - height: spacing.screenHeight * 0.28, + height: spacing.screenHeight * 0.27, } const $tabContainer: TextStyle = { diff --git a/src/services/walletService.ts b/src/services/walletService.ts index cca1091..a3b85b0 100644 --- a/src/services/walletService.ts +++ b/src/services/walletService.ts @@ -2089,7 +2089,7 @@ const handleReceivedEventTask = async function (encryptedEvent: NostrEvent): Pro // this is not valid for events sent from LNURL bridge, that are sent and signed by a minibits server key // and *** do not contain sentFrom *** // LEGACY, replaced by claim api let sentFromPubkey = directMessageEvent.pubkey - let sentFrom = NostrClient.getFirstTagValue(directMessageEvent.tags, 'from') + let sentFrom = NostrClient.getFirstTagValue(directMessageEvent.tags, 'from') as string let sentFromNpub = NostrClient.getNpubkey(sentFromPubkey) let contactFrom: Contact | undefined = undefined let zapSenderProfile: NostrProfile | undefined = undefined