Preload chain images (#3471)

This commit is contained in:
Jaco Greeff 2020-08-21 20:32:37 +02:00 committed by GitHub
parent 4e96f88cfa
commit 3534bda556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,10 +13,21 @@ interface Props {
onClick?: () => any;
}
function preloadSet (images: Record<string, any>): void {
Object.values(images).forEach((src): void => {
new Image().src = src as string;
});
}
function sanitize (value?: string): string {
return value?.toLowerCase().replace('-', ' ') || '';
}
// preload on app init
preloadSet(chainLogos);
preloadSet(namedLogos);
preloadSet(nodeLogos);
function ChainImg ({ className = '', logo, onClick }: Props): React.ReactElement<Props> {
const { systemChain, systemName } = useApi();
const [isEmpty, img] = useMemo((): [boolean, string] => {