mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 21:59:33 +00:00
29 lines
674 B
TypeScript
29 lines
674 B
TypeScript
import getApiUrl from '../configuration/getApiUrl';
|
|
import defaultChannelIcon from '/img/default-channel-icon.jpg';
|
|
|
|
type ChannelIconProps = {
|
|
channelId: string;
|
|
channelThumbUrl: string | undefined;
|
|
};
|
|
|
|
const ChannelIcon = ({ channelId, channelThumbUrl }: ChannelIconProps) => {
|
|
let src = `${getApiUrl()}${channelThumbUrl}`;
|
|
|
|
if (channelThumbUrl === undefined) {
|
|
src = defaultChannelIcon;
|
|
}
|
|
|
|
return (
|
|
<img
|
|
src={src}
|
|
alt={`${channelId}-thumb`}
|
|
onError={({ currentTarget }) => {
|
|
currentTarget.onerror = null; // prevents looping
|
|
currentTarget.src = defaultChannelIcon;
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default ChannelIcon;
|