Fix cryptocurrency icons
This commit is contained in:
parent
35187f0c67
commit
2f54640bea
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue