From 0c9bef405fa42c18add23a88b7b00ce85a17a2a5 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Sun, 8 Feb 2026 10:30:00 +0100 Subject: [PATCH] feat: add RUB and BRL currencies, make settings currency dropdown dynamic --- js/components/pages/page-settings.js | 9 ++++++--- js/services/currency.js | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/js/components/pages/page-settings.js b/js/components/pages/page-settings.js index d35a1db..5c075da 100644 --- a/js/components/pages/page-settings.js +++ b/js/components/pages/page-settings.js @@ -1,6 +1,7 @@ import { t, i18n } from '../../i18n.js' import { auth } from '../../services/auth.js' import { favoritesService } from '../../services/favorites.js' +import { getCurrencySymbol, SUPPORTED_CURRENCIES } from '../../services/currency.js' class PageSettings extends HTMLElement { constructor() { @@ -210,9 +211,11 @@ class PageSettings extends HTMLElement {
diff --git a/js/services/currency.js b/js/services/currency.js index 1236d11..caf48a4 100644 --- a/js/services/currency.js +++ b/js/services/currency.js @@ -13,7 +13,9 @@ const CURRENCY_SYMBOLS = { USD: '$', GBP: '£', CHF: 'CHF', - JPY: '¥' + JPY: '¥', + RUB: '₽', + BRL: 'R$' } const CACHE_DURATION = 60 * 60 * 1000 // 60 minutes (CoinGecko free tier is strict) @@ -90,7 +92,7 @@ async function fetchRates() { lastRequestTime = Date.now() try { - const currencies = 'eur,usd,gbp,chf,jpy' + const currencies = 'eur,usd,gbp,chf,jpy,rub,brl' const response = await fetch(`${COINGECKO_API}?ids=monero&vs_currencies=${currencies}`) // Handle rate limit response @@ -111,7 +113,9 @@ async function fetchRates() { USD: data.monero.usd, GBP: data.monero.gbp, CHF: data.monero.chf, - JPY: data.monero.jpy + JPY: data.monero.jpy, + RUB: data.monero.rub, + BRL: data.monero.brl } // Update cache @@ -135,7 +139,9 @@ function getDefaultRates() { USD: 165, GBP: 130, CHF: 145, - JPY: 24000 + JPY: 24000, + RUB: 15000, + BRL: 850 } } @@ -266,7 +272,7 @@ export function formatFiat(amount, currency) { }).format(amount) // Symbol before or after amount - if (['EUR', 'GBP', 'USD'].includes(currency)) { + if (['EUR', 'GBP', 'USD', 'BRL'].includes(currency)) { return `${symbol} ${formatted}` } return `${formatted} ${symbol}` @@ -284,7 +290,7 @@ export function getCurrencySymbol(currency) { /** * List of supported currencies */ -export const SUPPORTED_CURRENCIES = ['XMR', 'EUR', 'CHF', 'USD', 'GBP', 'JPY'] +export const SUPPORTED_CURRENCIES = ['XMR', 'EUR', 'CHF', 'USD', 'GBP', 'JPY', 'RUB', 'BRL'] export default { getXmrRates,