FIX: Notes were not persistent

This commit is contained in:
Marcos Rodriguez Velez 2024-05-26 18:10:38 -04:00
parent 555819a9b0
commit 07f07d3d38
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
4 changed files with 16 additions and 6 deletions

View File

@ -63,8 +63,8 @@ export enum WalletTransactionsStatus {
// @ts-ignore defaut value does not match the type
export const BlueStorageContext = createContext<BlueStorageContextType>(undefined);
export const BlueStorageProvider = ({ children }: { children: React.ReactNode }) => {
const txMetadata = useRef<TTXMetadata>(BlueApp.tx_metadata);
const counterpartyMetadata = useRef<TCounterpartyMetadata>(BlueApp.counterparty_metadata || {}); // init
const txMetadata = useRef<TTXMetadata>({});
const counterpartyMetadata = useRef<TCounterpartyMetadata>({}); // init
const getTransactions = BlueApp.getTransactions;
const fetchWalletBalances = BlueApp.fetchWalletBalances;
const fetchWalletTransactions = BlueApp.fetchWalletTransactions;
@ -94,6 +94,8 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode })
BlueElectrum.isDisabled().then(setIsElectrumDisabled);
if (walletsInitialized) {
setWallets(BlueApp.getWallets());
txMetadata.current = BlueApp.tx_metadata;
counterpartyMetadata.current = BlueApp.counterparty_metadata;
BlueElectrum.connectMain();
}
}, [walletsInitialized]);

View File

@ -12,11 +12,12 @@ interface HeaderRightButtonProps {
const HeaderRightButton: React.FC<HeaderRightButtonProps> = ({ disabled = true, onPress, title, testID }) => {
const { colors } = useTheme();
const opacity = disabled ? 0.5 : 1;
return (
<TouchableOpacity
accessibilityRole="button"
disabled={disabled}
style={[styles.save, { backgroundColor: colors.lightButton }]}
style={[styles.save, { backgroundColor: colors.lightButton }, { opacity }]}
onPress={onPress}
testID={testID}
>

View File

@ -21,7 +21,7 @@ import Broadcast from '../screen/send/Broadcast';
import IsItMyAddress from '../screen/send/isItMyAddress';
import Success from '../screen/send/success';
import CPFP from '../screen/transactions/CPFP';
import TransactionDetails from '../screen/transactions/details';
import TransactionDetails from '../screen/transactions/TransactionDetails';
import RBFBumpFee from '../screen/transactions/RBFBumpFee';
import RBFCancel from '../screen/transactions/RBFCancel';
import TransactionStatus from '../screen/transactions/TransactionStatus';

View File

@ -103,9 +103,16 @@ const TransactionDetails = () => {
}, [tx, txMetadata, memo, counterpartyLabel, paymentCode, saveToDisk, counterpartyMetadata]);
const HeaderRight = useMemo(
() => <HeaderRightButton disabled={isLoading} onPress={handleOnSaveButtonTapped} title={loc.wallets.details_save} />,
() =>
tx && (
<HeaderRightButton
disabled={txMetadata[tx.hash].memo === memo}
onPress={handleOnSaveButtonTapped}
title={loc.wallets.details_save}
/>
),
[isLoading, handleOnSaveButtonTapped],
[tx, txMetadata, memo, handleOnSaveButtonTapped],
);
useEffect(() => {