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';
|
|
|
|
|
2022-06-16 06:56:46 +02:00
|
|
|
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) {
|
2022-06-16 06:56:46 +02:00
|
|
|
setThumbnail(FileRenderPlaceholder);
|
|
|
|
} else {
|
|
|
|
setThumbnail(getThumbnailCdnUrl({ thumbnail: claimThumbnail, width: 1280, height: 720 }));
|
2022-06-14 15:43:41 +02:00
|
|
|
}
|
2022-06-16 06:56:46 +02:00
|
|
|
}, [claimThumbnail]);
|
2022-03-17 11:53:18 +01:00
|
|
|
|
|
|
|
return thumbnail;
|
|
|
|
}
|