From 088db5225863ad3cc721839aab86077b8c13daca Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Sun, 8 Feb 2026 10:46:29 +0100 Subject: [PATCH] fix: guard non-published listings for non-owners, locale-aware number format, accept all currencies as default --- js/components/pages/page-create.js | 2 +- js/components/pages/page-listing.js | 6 +++--- js/services/currency.js | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/js/components/pages/page-create.js b/js/components/pages/page-create.js index 708aee8..73429d1 100644 --- a/js/components/pages/page-create.js +++ b/js/components/pages/page-create.js @@ -32,7 +32,7 @@ class PageCreate extends HTMLElement { // Use user's preferred currency from settings as default const defaultCurrency = getDisplayCurrency() // Map display currencies to listing currencies (XMR not for fiat listings) - const currency = ['EUR', 'USD', 'CHF'].includes(defaultCurrency) ? defaultCurrency : 'EUR' + const currency = (SUPPORTED_CURRENCIES.includes(defaultCurrency) && defaultCurrency !== 'XMR') ? defaultCurrency : 'EUR' return { title: '', diff --git a/js/components/pages/page-listing.js b/js/components/pages/page-listing.js index 82ecf92..b7c5921 100644 --- a/js/components/pages/page-listing.js +++ b/js/components/pages/page-listing.js @@ -199,11 +199,11 @@ class PageListing extends HTMLElement { return } - if (this.listing.status === 'deleted' && !this.isOwner) { + if (this.listing.status !== 'published' && !this.isOwner) { this.innerHTML = /* html */`
-
🗑️
-

${t('messages.listingRemoved')}

+
😕
+

${t('listing.notFound')}

${t('listing.backHome')}
` diff --git a/js/services/currency.js b/js/services/currency.js index caf48a4..56218ee 100644 --- a/js/services/currency.js +++ b/js/services/currency.js @@ -265,13 +265,21 @@ export function formatXmr(amount) { */ export function formatFiat(amount, currency) { const symbol = CURRENCY_SYMBOLS[currency] || currency - - const formatted = new Intl.NumberFormat('de-DE', { + + let locale = 'en-US' + try { + const stored = localStorage.getItem('locale') + const localeMap = { de: 'de-DE', en: 'en-US', fr: 'fr-FR', it: 'it-IT', es: 'es-ES', pt: 'pt-BR', ru: 'ru-RU' } + locale = localeMap[stored] || 'en-US' + } catch (e) { + // Fallback + } + + const formatted = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount) - // Symbol before or after amount if (['EUR', 'GBP', 'USD', 'BRL'].includes(currency)) { return `${symbol} ${formatted}` }