REF: Remove need to type .current

This commit is contained in:
Marcos Rodriguez Velez 2024-05-13 13:17:19 -04:00
parent 6845f8eaaa
commit ef90a4daf4
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
4 changed files with 14 additions and 14 deletions

View file

@ -18,8 +18,8 @@ const _lastTimeTriedToRefetchWallet: { [walletID: string]: number } = {};
interface BlueStorageContextType {
wallets: TWallet[];
setWalletsWithNewOrder: (wallets: TWallet[]) => void;
txMetadata: React.MutableRefObject<TTXMetadata>;
counterpartyMetadata: React.MutableRefObject<TCounterpartyMetadata>;
txMetadata: TTXMetadata;
counterpartyMetadata: TCounterpartyMetadata;
saveToDisk: (force?: boolean) => Promise<void>;
selectedWalletID: string | undefined;
setSelectedWalletID: (walletID: string | undefined) => void;
@ -233,8 +233,8 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode })
() => ({
wallets,
setWalletsWithNewOrder,
txMetadata,
counterpartyMetadata,
txMetadata: txMetadata.current,
counterpartyMetadata: counterpartyMetadata.current,
saveToDisk,
getTransactions,
selectedWalletID,

View file

@ -61,9 +61,9 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
let counterparty;
if (item.counterparty) {
counterparty = counterpartyMetadata.current?.[item.counterparty]?.label ?? item.counterparty;
counterparty = counterpartyMetadata?.[item.counterparty]?.label ?? item.counterparty;
}
const txMemo = (counterparty ? `[${shortenContactName(counterparty)}] ` : '') + (txMetadata.current[item.hash]?.memo ?? '');
const txMemo = (counterparty ? `[${shortenContactName(counterparty)}] ` : '') + (txMetadata[item.hash]?.memo ?? '');
const subtitle = useMemo(() => {
let sub = Number(item.confirmations) < 7 ? loc.formatString(loc.transactions.list_conf, { number: item.confirmations }) : '';
if (sub !== '') sub += ' ';

View file

@ -432,12 +432,12 @@ const TransactionStatus = () => {
};
const renderTXMetadata = () => {
if (txMetadata.current[tx.hash]) {
if (txMetadata.current[tx.hash].memo) {
if (txMetadata[tx.hash]) {
if (txMetadata[tx.hash].memo) {
return (
<View style={styles.memo}>
<Text selectable style={styles.memoText}>
{txMetadata.current[tx.hash].memo}
{txMetadata[tx.hash].memo}
</Text>
</View>
);
@ -449,7 +449,7 @@ const TransactionStatus = () => {
if (!tx.counterparty) return; // no BIP47 counterparty for this tx, return early
// theres a counterparty. lets lookup if theres an alias for him
let counterparty = counterpartyMetadata.current?.[tx.counterparty]?.label ?? tx.counterparty;
let counterparty = counterpartyMetadata?.[tx.counterparty]?.label ?? tx.counterparty;
counterparty = shortenCounterpartyName(counterparty);
return (

View file

@ -67,9 +67,9 @@ const TransactionDetails = () => {
const handleOnSaveButtonTapped = useCallback(() => {
Keyboard.dismiss();
if (!tx) return;
txMetadata.current[tx.hash] = { memo };
txMetadata[tx.hash] = { memo };
if (counterpartyLabel && paymentCode) {
counterpartyMetadata.current[paymentCode] = { label: counterpartyLabel };
counterpartyMetadata[paymentCode] = { label: counterpartyLabel };
}
saveToDisk().then(_success => {
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
@ -117,13 +117,13 @@ const TransactionDetails = () => {
// okay, this txid _was_ with someone using payment codes, so we show the label edit dialog
// and load user-defined alias for the pc if any
setCounterpartyLabel(counterpartyMetadata ? counterpartyMetadata.current[foundPaymentCode]?.label ?? '' : '');
setCounterpartyLabel(counterpartyMetadata ? counterpartyMetadata[foundPaymentCode]?.label ?? '' : '');
setIsCounterpartyLabelVisible(true);
setPaymentCode(foundPaymentCode);
}
}
setMemo(txMetadata.current[foundTx.hash]?.memo ?? '');
setMemo(txMetadata[foundTx.hash]?.memo ?? '');
setTX(foundTx);
setFrom(newFrom);
setTo(newTo);