Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
let app = this.props.app,
iconName = app.options.iconName;
// No icon selected - render SimpleFooter
if (iconName === null) {
return ;
}
// Check if icon has been loaded
if (!Iconify.iconExists(iconName)) {
Iconify.preloadImages([iconName]);
if (!this._listener) {
this._listener = this._onIconsLoaded.bind(this);
document.addEventListener('IconifyAddedIcons', this._listener, true);
}
return ;
}
// Loaded
return ;
}
block = props.view.blocks[name],
options = props.app.options,
list = options.list,
selectedIcon = options.iconName,
Component = list ? LongIcon : Icon;
if (!block || block.empty()) {
return null;
}
// Pre-load all icons
let missing = block.icons.filter(
icon => !Iconify.iconExists(icon.prefix + ':' + icon.name)
);
if (missing.length) {
Iconify.preloadImages(missing.map(icon => icon.prefix + ':' + icon.name));
}
// Render all icons
let icons = [];
block.icons.forEach(icon => {
let key = icon.prefix + ':' + icon.name;
// Icon name
let title = key;
if (props.view.type === 'collection') {
// Do not show prefix when viewing collection
title = icon.name;
}
icons.push(