diff --git a/src/assets/cryptocurrency/doge.svg b/src/assets/cryptocurrency/doge.svg new file mode 100644 index 000000000..c22bf09bd --- /dev/null +++ b/src/assets/cryptocurrency/doge.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/features/crypto-donate/components/crypto-icon.tsx b/src/features/crypto-donate/components/crypto-icon.tsx index c42327bbe..45b78e040 100644 --- a/src/features/crypto-donate/components/crypto-icon.tsx +++ b/src/features/crypto-donate/components/crypto-icon.tsx @@ -1,10 +1,14 @@ import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg'; +const icons = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true }); + /** Get crypto icon URL by ticker symbol, or fall back to generic icon */ function getIcon(ticker: string): string { - try { - return new URL(`../../../assets/cryptocurrency/${ticker}.svg`, import.meta.url).href; - } catch { + const iconPath = `../../../assets/cryptocurrency/${ticker}.svg`; + + if (icons[iconPath]) { + return new URL(iconPath, import.meta.url).href; + } else { return genericIcon; } }