add setttings item to hide small transactions on homescreen
This commit is contained in:
@@ -210,6 +210,7 @@ export default function HomeLightning({ navigation }) {
|
||||
const homepageTxPreferance = masterInfoObject.homepageTxPreferance;
|
||||
const userBalanceDenomination = masterInfoObject.userBalanceDenomination;
|
||||
const didViewSeedPhrase = masterInfoObject?.didViewSeedPhrase;
|
||||
const hideSmallPaymentsHomepage = masterInfoObject?.hideSmallPaymentsHomepage;
|
||||
|
||||
const BALANCE_FADE_START = navbarHeight;
|
||||
const BALANCE_FADE_END = 100;
|
||||
@@ -296,6 +297,7 @@ export default function HomeLightning({ navigation }) {
|
||||
scrollPosition,
|
||||
poolInfoRef,
|
||||
t,
|
||||
hideSmallPaymentsHomepage,
|
||||
}) || []
|
||||
);
|
||||
}, [
|
||||
@@ -310,6 +312,7 @@ export default function HomeLightning({ navigation }) {
|
||||
darkModeType,
|
||||
t,
|
||||
showTokensInformation,
|
||||
hideSmallPaymentsHomepage,
|
||||
]);
|
||||
|
||||
const handleRefresh = useCallback(async () => {
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
COLORS,
|
||||
HIDDEN_BALANCE_TEXT,
|
||||
SIZES,
|
||||
SMALL_BTC_PAYMENT_LIMIT,
|
||||
SMALL_USD_PAYMENT_LIMIT,
|
||||
} from '../../../../constants';
|
||||
import { useGlobalContextProvider } from '../../../../../context-store/context';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
@@ -90,6 +92,7 @@ export default function DisplayOptions() {
|
||||
const saveTimeoutRef = useRef(null);
|
||||
const navigate = useNavigation();
|
||||
const { updateHomepageTxPreferance } = useSparkWallet();
|
||||
const hideSmallPaymentsHomepage = masterInfoObject?.hideSmallPaymentsHomepage;
|
||||
|
||||
const dropdownOptions = [15, 20, 25, 30, 35, 40].map(value => ({
|
||||
label: t('settings.displayOptions.transactionsLabel', { context: value }),
|
||||
@@ -121,6 +124,11 @@ export default function DisplayOptions() {
|
||||
}
|
||||
};
|
||||
|
||||
const updateSmallPaymentSettings = update => {
|
||||
toggleMasterInfoObject({ hideSmallPaymentsHomepage: update });
|
||||
updateHomepageTxPreferance(masterInfoObject.homepageTxPreferance, update);
|
||||
};
|
||||
|
||||
const containerBackground = backgroundOffset;
|
||||
|
||||
return (
|
||||
@@ -284,6 +292,41 @@ export default function DisplayOptions() {
|
||||
dropdownItemCustomStyles={{ justifyContent: 'start' }}
|
||||
textStyles={{ paddingRight: 20 }}
|
||||
/>
|
||||
|
||||
<View style={[styles.divider, { backgroundColor }]} />
|
||||
|
||||
<SettingsItem
|
||||
isLast={true}
|
||||
label={t('settings.displayOptions.hideSmallPayments')}
|
||||
description={t('settings.displayOptions.hideSmallPaymentsDesc', {
|
||||
btcAmount: displayCorrectDenomination({
|
||||
amount: SMALL_BTC_PAYMENT_LIMIT,
|
||||
masterInfoObject: {
|
||||
...masterInfoObject,
|
||||
userBalanceDenomination: 'sats',
|
||||
},
|
||||
fiatStats,
|
||||
}),
|
||||
dollarAmount: displayCorrectDenomination({
|
||||
amount: SMALL_USD_PAYMENT_LIMIT,
|
||||
masterInfoObject: {
|
||||
...masterInfoObject,
|
||||
userBalanceDenomination: 'fiat',
|
||||
},
|
||||
fiatStats,
|
||||
convertAmount: false,
|
||||
forceCurrency: 'USD',
|
||||
}),
|
||||
})}
|
||||
>
|
||||
<CustomToggleSwitch
|
||||
stateValue={hideSmallPaymentsHomepage}
|
||||
toggleSwitchFunction={() =>
|
||||
updateSmallPaymentSettings(!hideSmallPaymentsHomepage)
|
||||
}
|
||||
page={'cameraSlider'}
|
||||
/>
|
||||
</SettingsItem>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
|
||||
|
||||
@@ -130,6 +130,9 @@ const FORCE_RESET_SPAARK_STATE_MS = 6 * 60 * 1000;
|
||||
|
||||
const DEFAULT_PAYMENT_EXPIRY_SEC = 60 * 60 * 12;
|
||||
|
||||
const SMALL_BTC_PAYMENT_LIMIT = 500;
|
||||
const SMALL_USD_PAYMENT_LIMIT = 0.05;
|
||||
|
||||
const SCREEN_DIMENSIONS = Dimensions.get('screen');
|
||||
|
||||
const USDB_TOKEN_ID =
|
||||
@@ -242,4 +245,6 @@ export {
|
||||
NEAR_BUDGET_LIMIT,
|
||||
MIN_USD_BTC_LIGHTNING_SWAP,
|
||||
BARCODE_FORMATS,
|
||||
SMALL_BTC_PAYMENT_LIMIT,
|
||||
SMALL_USD_PAYMENT_LIMIT,
|
||||
};
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
ICONS,
|
||||
SIZES,
|
||||
SKELETON_ANIMATION_SPEED,
|
||||
SMALL_BTC_PAYMENT_LIMIT,
|
||||
SMALL_USD_PAYMENT_LIMIT,
|
||||
USDB_TOKEN_ID,
|
||||
} from '../constants';
|
||||
import GetThemeColors from '../hooks/themeColors';
|
||||
@@ -40,6 +42,30 @@ const TRANSACTION_CONSTANTS = {
|
||||
UNKOWN: 'unknown',
|
||||
};
|
||||
|
||||
const shouldHideSmallPayment = ({
|
||||
frompage,
|
||||
hideSmallPaymentsHomepage,
|
||||
paymentDetails,
|
||||
isLRC20Payment,
|
||||
tokenDecimals,
|
||||
}) => {
|
||||
if (frompage !== TRANSACTION_CONSTANTS.HOME || !hideSmallPaymentsHomepage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const amount = Math.abs(Number(paymentDetails?.amount));
|
||||
if (!Number.isFinite(amount)) return false;
|
||||
|
||||
if (isLRC20Payment) {
|
||||
if (paymentDetails?.LRC20Token !== USDB_TOKEN_ID) return false;
|
||||
const decimals = Number(tokenDecimals ?? 6);
|
||||
const usdAmount = amount / 10 ** decimals;
|
||||
return usdAmount < SMALL_USD_PAYMENT_LIMIT;
|
||||
}
|
||||
|
||||
return amount < SMALL_BTC_PAYMENT_LIMIT;
|
||||
};
|
||||
|
||||
const SKELETON_STYLES = {
|
||||
icon: {
|
||||
height: 40,
|
||||
@@ -227,6 +253,7 @@ export default function getFormattedHomepageTxsForSpark(props) {
|
||||
scrollPosition,
|
||||
poolInfoRef,
|
||||
t,
|
||||
hideSmallPaymentsHomepage,
|
||||
} = props;
|
||||
|
||||
// Remove unnecessary console.logs for performance
|
||||
@@ -301,6 +328,17 @@ export default function getFormattedHomepageTxsForSpark(props) {
|
||||
(!paymentDetails.completedSwaptoUSD ||
|
||||
!ln_funding_txIds.has(currentTransaction.sparkID));
|
||||
|
||||
if (
|
||||
shouldHideSmallPayment({
|
||||
frompage,
|
||||
hideSmallPaymentsHomepage,
|
||||
paymentDetails,
|
||||
isLRC20Payment,
|
||||
tokenDecimals: hasSavedTokenData?.tokenMetadata?.decimals,
|
||||
})
|
||||
)
|
||||
continue;
|
||||
|
||||
// Early continue conditions
|
||||
if (
|
||||
!enabledLRC20 &&
|
||||
|
||||
@@ -98,6 +98,7 @@ export default async function initializeUserSettingsFromHistory({
|
||||
monthlyBudget,
|
||||
bitrefillEmail,
|
||||
spendAndReplace,
|
||||
hideSmallPaymentsHomepage,
|
||||
} = localStoredData;
|
||||
|
||||
if (blitzStoredData === null) throw Error('Failed to retrive');
|
||||
@@ -411,6 +412,7 @@ export default async function initializeUserSettingsFromHistory({
|
||||
tempObject['lnurlReceiveCurrency'] = lnurlReceiveCurrency;
|
||||
tempObject['bitrefillEmail'] = bitrefillEmail;
|
||||
tempObject[SPEND_AND_REPLACE_STORAGE_KEY] = spendAndReplace;
|
||||
tempObject['hideSmallPaymentsHomepage'] = hideSmallPaymentsHomepage;
|
||||
|
||||
// store in contacts context
|
||||
tempObject['contacts'] = contacts;
|
||||
|
||||
@@ -34,6 +34,7 @@ const keys = [
|
||||
'monthlyBudget',
|
||||
'bitrefillEmail',
|
||||
SPEND_AND_REPLACE_STORAGE_KEY,
|
||||
'hideSmallPaymentsHomepage',
|
||||
];
|
||||
|
||||
const defaultValues = {
|
||||
@@ -73,6 +74,7 @@ const defaultValues = {
|
||||
monthlyBudget: null,
|
||||
bitrefillEmail: '',
|
||||
[SPEND_AND_REPLACE_STORAGE_KEY]: { isEnabled: false },
|
||||
hideSmallPaymentsHomepage: false,
|
||||
};
|
||||
|
||||
export const fetchLocalStorageItems = async () => {
|
||||
@@ -121,6 +123,8 @@ export const fetchLocalStorageItems = async () => {
|
||||
monthlyBudget: parsedResults[22] ?? defaultValues.monthlyBudget,
|
||||
bitrefillEmail: parsedResults[23] ?? defaultValues.bitrefillEmail,
|
||||
spendAndReplace: parsedResults[24] ?? defaultValues.spendAndReplace,
|
||||
hideSmallPaymentsHomepage:
|
||||
parsedResults[25] ?? defaultValues.hideSmallPaymentsHomepage,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
import {USDB_TOKEN_ID} from '../../constants';
|
||||
import {isFlashnetTransfer} from './handleFlashnetTransferIds';
|
||||
import {
|
||||
SMALL_BTC_PAYMENT_LIMIT,
|
||||
SMALL_USD_PAYMENT_LIMIT,
|
||||
USDB_TOKEN_ID,
|
||||
} from '../../constants';
|
||||
import { isFlashnetTransfer } from './handleFlashnetTransferIds';
|
||||
|
||||
const shouldHideSmallPayment = ({
|
||||
hideSmallPaymentsHomepage,
|
||||
paymentDetails,
|
||||
isLRC20Payment,
|
||||
tokenDecimals,
|
||||
}) => {
|
||||
if (!hideSmallPaymentsHomepage) return false;
|
||||
|
||||
const amount = Math.abs(Number(paymentDetails?.amount));
|
||||
if (!Number.isFinite(amount)) return false;
|
||||
|
||||
if (isLRC20Payment) {
|
||||
if (paymentDetails?.LRC20Token !== USDB_TOKEN_ID) return false;
|
||||
const decimals = Number(tokenDecimals ?? 6);
|
||||
const usdAmount = amount / 10 ** decimals;
|
||||
return usdAmount < SMALL_USD_PAYMENT_LIMIT;
|
||||
}
|
||||
|
||||
return amount < SMALL_BTC_PAYMENT_LIMIT;
|
||||
};
|
||||
|
||||
export function filterDisplayableTransactions({
|
||||
transactions,
|
||||
@@ -9,6 +34,7 @@ export function filterDisplayableTransactions({
|
||||
forcedPendingMap,
|
||||
appliedEpoch = 0,
|
||||
limit = 25,
|
||||
hideSmallPaymentsHomepage,
|
||||
}) {
|
||||
if (!transactions?.length) return [];
|
||||
|
||||
@@ -35,10 +61,19 @@ export function filterDisplayableTransactions({
|
||||
lnFundingTxIds.add(paymentDetails.ln_funding_id);
|
||||
}
|
||||
|
||||
if (
|
||||
shouldHideSmallPayment({
|
||||
hideSmallPaymentsHomepage,
|
||||
paymentDetails,
|
||||
isLRC20Payment,
|
||||
tokenDecimals: hasSavedTokenData?.tokenMetadata?.decimals,
|
||||
})
|
||||
)
|
||||
continue;
|
||||
|
||||
const showSwapConversion =
|
||||
paymentDetails.performSwaptoUSD &&
|
||||
(!paymentDetails.completedSwaptoUSD ||
|
||||
!lnFundingTxIds.has(tx.sparkID));
|
||||
(!paymentDetails.completedSwaptoUSD || !lnFundingTxIds.has(tx.sparkID));
|
||||
|
||||
// Static filters
|
||||
if (
|
||||
@@ -87,8 +122,12 @@ export function filterDisplayableTransactions({
|
||||
|
||||
// Apply pending flag
|
||||
const pendingMeta = forcedPendingMap?.get(tx.sparkID);
|
||||
if (pendingMeta && pendingMeta.epoch > appliedEpoch && !tx.isBalancePending) {
|
||||
result.push({...tx, isBalancePending: true});
|
||||
if (
|
||||
pendingMeta &&
|
||||
pendingMeta.epoch > appliedEpoch &&
|
||||
!tx.isBalancePending
|
||||
) {
|
||||
result.push({ ...tx, isBalancePending: true });
|
||||
} else {
|
||||
result.push(tx);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ const SparkWalletProvider = ({ children }) => {
|
||||
timestamp: 0,
|
||||
});
|
||||
const homepageTxPreferance = masterInfoObject.homepageTxPreferance;
|
||||
const hideSmallPaymentsHomepage = masterInfoObject.hideSmallPaymentsHomepage;
|
||||
|
||||
const showTokensInformation =
|
||||
masterInfoObject.enabledBTKNTokens === null
|
||||
@@ -639,10 +640,11 @@ const SparkWalletProvider = ({ children }) => {
|
||||
forcedPendingMap: forcedPendingBySparkIdRef.current,
|
||||
appliedEpoch: balanceEpochRef.current.applied,
|
||||
limit: homepageTxPreferance,
|
||||
hideSmallPaymentsHomepage,
|
||||
});
|
||||
setSparkInformation(prev => ({ ...prev, transactions: filtered }));
|
||||
},
|
||||
[showTokensInformation, homepageTxPreferance],
|
||||
[showTokensInformation, homepageTxPreferance, hideSmallPaymentsHomepage],
|
||||
);
|
||||
|
||||
const updateHomepageScrollPosition = useCallback(
|
||||
@@ -660,15 +662,16 @@ const SparkWalletProvider = ({ children }) => {
|
||||
forcedPendingMap: forcedPendingBySparkIdRef.current,
|
||||
appliedEpoch: balanceEpochRef.current.applied,
|
||||
limit: homepageTxPreferance,
|
||||
hideSmallPaymentsHomepage,
|
||||
});
|
||||
if (scrollPositionRef.current !== pos) return;
|
||||
setSparkInformation(prev => ({ ...prev, transactions: filtered }));
|
||||
},
|
||||
[showTokensInformation, homepageTxPreferance],
|
||||
[showTokensInformation, homepageTxPreferance, hideSmallPaymentsHomepage],
|
||||
);
|
||||
|
||||
const updateHomepageTxPreferance = useCallback(
|
||||
async num => {
|
||||
async (num, smallPaymentOverrides) => {
|
||||
const allTxs = await getAllSparkTransactions({
|
||||
limit: null,
|
||||
accountId: sparkInfoRef.current.identityPubKey,
|
||||
@@ -681,10 +684,12 @@ const SparkWalletProvider = ({ children }) => {
|
||||
forcedPendingMap: forcedPendingBySparkIdRef.current,
|
||||
appliedEpoch: balanceEpochRef.current.applied,
|
||||
limit: num,
|
||||
hideSmallPaymentsHomepage:
|
||||
smallPaymentOverrides ?? hideSmallPaymentsHomepage,
|
||||
});
|
||||
setSparkInformation(prev => ({ ...prev, transactions: filtered }));
|
||||
},
|
||||
[showTokensInformation],
|
||||
[showTokensInformation, hideSmallPaymentsHomepage],
|
||||
);
|
||||
|
||||
const enqueueTxLane = useCallback((updateType, task) => {
|
||||
|
||||
@@ -46,6 +46,7 @@ const PRESET_LOCAL_DATA = {
|
||||
pinnedAccounts: [],
|
||||
monthlyBudget: null,
|
||||
bitrefillEmail: '',
|
||||
hideSmallPaymentsHomepage: false,
|
||||
};
|
||||
|
||||
async function sendDataToDB(newObject, uuid) {
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Anzeigeformat",
|
||||
"homepage": "Startseite",
|
||||
"txToDisplay": "Anzuzeigende Transaktionen",
|
||||
"hideSmallPayments": "Kleine Zahlungen ausblenden",
|
||||
"hideSmallPaymentsDesc": "Bitcoin-Zahlungen unter {{btcAmount}} und Dollar-Zahlungen unter {{dollarAmount}} ausblenden.",
|
||||
"transactionsLabel_15": "15 Transaktionen",
|
||||
"transactionsLabel_20": "20 Transaktionen",
|
||||
"transactionsLabel_25": "25 Transaktionen",
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Display Format",
|
||||
"homepage": "Homepage",
|
||||
"txToDisplay": "Transactions to Display",
|
||||
"hideSmallPayments": "Hide Small Payments",
|
||||
"hideSmallPaymentsDesc": "Hide Bitcoin payments under {{btcAmount}} and Dollar payments under {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 Transactions",
|
||||
"transactionsLabel_20": "20 Transactions",
|
||||
"transactionsLabel_25": "25 Transactions",
|
||||
|
||||
@@ -1592,6 +1592,8 @@
|
||||
"displayForm": "Formato de visualización",
|
||||
"homepage": "Página principal",
|
||||
"txToDisplay": "Transacciones a mostrar",
|
||||
"hideSmallPayments": "Ocultar pagos pequeños",
|
||||
"hideSmallPaymentsDesc": "Oculta los pagos de Bitcoin menores de {{btcAmount}} y los pagos en dólares menores de {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 transacciones",
|
||||
"transactionsLabel_20": "20 transacciones",
|
||||
"transactionsLabel_25": "25 transacciones",
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Format d'affichage",
|
||||
"homepage": "Page d'accueil",
|
||||
"txToDisplay": "Transactions à afficher",
|
||||
"hideSmallPayments": "Masquer les petits paiements",
|
||||
"hideSmallPaymentsDesc": "Masquer les paiements Bitcoin inférieurs à {{btcAmount}} et les paiements en dollars inférieurs à {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 Transactions",
|
||||
"transactionsLabel_20": "20 Transactions",
|
||||
"transactionsLabel_25": "25 Transactions",
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Formato di visualizzazione",
|
||||
"homepage": "Pagina iniziale",
|
||||
"txToDisplay": "Transazioni da mostrare",
|
||||
"hideSmallPayments": "Nascondi piccoli pagamenti",
|
||||
"hideSmallPaymentsDesc": "Nascondi i pagamenti in Bitcoin inferiori a {{btcAmount}} e i pagamenti in dollari inferiori a {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 transazioni",
|
||||
"transactionsLabel_20": "20 transazioni",
|
||||
"transactionsLabel_25": "25 transazioni",
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Formato de exibição",
|
||||
"homepage": "Página inicial",
|
||||
"txToDisplay": "Máximo de exibições",
|
||||
"hideSmallPayments": "Ocultar pagamentos pequenos",
|
||||
"hideSmallPaymentsDesc": "Oculta pagamentos em Bitcoin abaixo de {{btcAmount}} e pagamentos em dólar abaixo de {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 transações",
|
||||
"transactionsLabel_20": "20 transações",
|
||||
"transactionsLabel_25": "25 transações",
|
||||
|
||||
@@ -1596,6 +1596,8 @@
|
||||
"displayForm": "Формат",
|
||||
"homepage": "Главная",
|
||||
"txToDisplay": "Транзакций в списке",
|
||||
"hideSmallPayments": "Скрывать мелкие платежи",
|
||||
"hideSmallPaymentsDesc": "Скрывать платежи Bitcoin меньше {{btcAmount}} и долларовые платежи меньше {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 транзакций",
|
||||
"transactionsLabel_20": "20 транзакций",
|
||||
"transactionsLabel_25": "25 транзакций",
|
||||
|
||||
@@ -1595,6 +1595,8 @@
|
||||
"displayForm": "Visningsformat",
|
||||
"homepage": "Hemsida",
|
||||
"txToDisplay": "Transaktioner som ska visas",
|
||||
"hideSmallPayments": "Dölj små betalningar",
|
||||
"hideSmallPaymentsDesc": "Dölj Bitcoin-betalningar under {{btcAmount}} och dollarbetalningar under {{dollarAmount}}.",
|
||||
"transactionsLabel_15": "15 Transaktioner",
|
||||
"transactionsLabel_20": "20 Transaktioner",
|
||||
"transactionsLabel_25": "25 Transaktioner",
|
||||
|
||||
Reference in New Issue
Block a user