diff --git a/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts b/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts index 8bce815009..2ba39f4ef8 100644 --- a/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts +++ b/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts @@ -2,7 +2,8 @@ import {Notification, Notifications} from '@jamsinclair/react-native-notificatio import {mountAsyncStorage} from '@yoroi/common' import {Notifications as NotificationTypes} from '@yoroi/types' -import {getCurrencySymbol} from '../../../Settings/useCases/changeAppSettings/Currency/CurrencyContext' +import {configCurrencies} from '../../../../kernel/constants' +import {formatCurrency, getCurrencySymbol} from '../../../Settings/useCases/changeAppSettings/Currency/CurrencyContext' export const generateNotificationId = (): number => { return generateRandomInteger(0, Number.MAX_SAFE_INTEGER) @@ -28,11 +29,11 @@ export const displayNotificationEvent = async (notificationEvent: NotificationTy if (notificationEvent.trigger === NotificationTypes.Trigger.PrimaryTokenPriceChanged) { const appStorage = mountAsyncStorage({path: '/'}) const currencyCode = await getCurrencySymbol(appStorage) - const newPrice = `${notificationEvent.metadata.nextPrice.toFixed(2)}${currencyCode}` + const newPrice = formatCurrency(notificationEvent.metadata.nextPrice, currencyCode) sendNotification({ title: 'Primary token price changed', - body: `The price of the primary token has changed to ${newPrice}`, + body: `The price of the primary token has changed to ${newPrice}.`, id: notificationEvent.id, }) } diff --git a/apps/wallet-mobile/src/features/Settings/useCases/changeAppSettings/Currency/CurrencyContext.tsx b/apps/wallet-mobile/src/features/Settings/useCases/changeAppSettings/Currency/CurrencyContext.tsx index 438ba04ac1..430c5b548b 100644 --- a/apps/wallet-mobile/src/features/Settings/useCases/changeAppSettings/Currency/CurrencyContext.tsx +++ b/apps/wallet-mobile/src/features/Settings/useCases/changeAppSettings/Currency/CurrencyContext.tsx @@ -55,6 +55,10 @@ export const getCurrencySymbol = async (storage: App.Storage) => { return defaultCurrency } +export const formatCurrency = (value: number, currency: CurrencySymbol) => { + return `${value.toFixed(configCurrencies[currency].decimals)} ${currency}` +} + const useSaveCurrency = ({onSuccess, ...options}: UseMutationOptions = {}) => { const queryClient = useQueryClient() const storage = useAsyncStorage()