Merge branch 'fix-crypto-icons' into 'main'

Fix cryptocurrency icons

See merge request soapbox-pub/soapbox!3239
This commit is contained in:
Alex Gleason 2024-11-11 04:09:02 +00:00
commit 8a4e85010d
1 changed files with 2 additions and 7 deletions

View File

@ -1,16 +1,11 @@
import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg'; import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg';
const icons = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true }); const icons: Record<string, { default: string }> = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true });
/** Get crypto icon URL by ticker symbol, or fall back to generic icon */ /** Get crypto icon URL by ticker symbol, or fall back to generic icon */
function getIcon(ticker: string): string { function getIcon(ticker: string): string {
const iconPath = `../../../assets/cryptocurrency/${ticker}.svg`; const iconPath = `../../../assets/cryptocurrency/${ticker}.svg`;
return icons[iconPath]?.default || genericIcon;
if (icons[iconPath]) {
return new URL(iconPath, import.meta.url).href;
} else {
return genericIcon;
}
} }
interface ICryptoIcon { interface ICryptoIcon {