lbry-desktop/ui/effects/use-get-poster.js

20 lines
596 B
JavaScript
Raw Normal View History

2022-03-17 11:53:18 +01:00
// @flow
import { getThumbnailCdnUrl } from 'util/thumbnail';
import React from 'react';
// $FlowFixMe cannot resolve ...
import FileRenderPlaceholder from 'static/img/fileRenderPlaceholder.png';
export default function useGetPoster(claimThumbnail: ?string) {
2022-03-17 11:53:18 +01:00
const [thumbnail, setThumbnail] = React.useState(FileRenderPlaceholder);
React.useEffect(() => {
2022-06-14 15:43:41 +02:00
if (!claimThumbnail) {
setThumbnail(FileRenderPlaceholder);
} else {
setThumbnail(getThumbnailCdnUrl({ thumbnail: claimThumbnail, width: 1280, height: 720 }));
2022-06-14 15:43:41 +02:00
}
}, [claimThumbnail]);
2022-03-17 11:53:18 +01:00
return thumbnail;
}