ca116ba010
wip wip - everything but publish, autoplay, and styling collection publishing add channel to collection publish cleanup wip bump clear mass add after success move collection item management controls redirect replace to published collection id bump playlist selector on create bump use new collection add ui element bump wip gitignore add content json wip bump context add to playlist basic collections page style pass wip wip: edits, buttons, styles... change fileAuthor to claimAuthor update, pending bugfixes, delete modal progress, collection header, other bugfixes bump cleaning show page bugfix builtin collection headers no playlists, no grid title wip style tweaks use normal looking claim previews for collection tiles add collection changes style library previews collection menulist for delete/view on library delete modal works for unpublished rearrange collection publish tabs clean up collection publishing and items show on odysee begin collectoin edit header and css renaming better thumbnails bump fix collection publish redirect view collection in menu does something copy and thumbs list previews, pending, context menus, list page enter to add collection, lists page empty state playable lists only, delete feature, bump put fileListDownloaded back better collection titles improve collection claim details fix horiz more icon fix up channel page style, copy, bump refactor preview overlay properties, fix reposts showing as floppydisk add watch later toast, small overlay properties on wunderbar results, fix collection actions buttons bump cleanup cleaning, refactoring bump preview thumb styling, cleanup support discover page lists search sync, bump bump, fix sync more enforce builtin order for now new lists page empty state try to indicate unpublished edits in lists bump fix autoplay and linting consts, fix autoplay bugs fixes cleanup fix, bump lists experimental ui, fixes refactor listIndex out hack in collection fallback thumb bump
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import { generateStreamUrl } from 'util/web';
|
|
|
|
export default function useGetThumbnail(
|
|
uri: string,
|
|
claim: ?Claim,
|
|
streamingUrl: ?string,
|
|
getFile: string => void,
|
|
shouldHide: boolean
|
|
) {
|
|
let thumbnailToUse;
|
|
|
|
// $FlowFixMe
|
|
const isImage = claim && claim.value && claim.value.stream_type === 'image';
|
|
// $FlowFixMe
|
|
const isFree = claim && claim.value && (!claim.value.fee || Number(claim.value.fee.amount) <= 0);
|
|
const isCollection = claim && claim.value_type === 'collection';
|
|
const thumbnailInClaim = claim && claim.value && claim.value.thumbnail && claim.value.thumbnail.url;
|
|
|
|
// @if TARGET='web'
|
|
if (thumbnailInClaim) {
|
|
thumbnailToUse = thumbnailInClaim;
|
|
} else if (claim && isImage && isFree) {
|
|
thumbnailToUse = generateStreamUrl(claim.name, claim.claim_id);
|
|
} else if (isCollection) {
|
|
thumbnailToUse = 'http://spee.ch/default-thumb-odysee:e.jpg';
|
|
}
|
|
// @endif
|
|
|
|
// @if TARGET='app'
|
|
thumbnailToUse = thumbnailInClaim;
|
|
|
|
//
|
|
// Temporarily disabled until we can call get with "save_blobs: off"
|
|
//
|
|
// React.useEffect(() => {
|
|
// if (hasClaim && isImage && isFree) {
|
|
// if (streamingUrl) {
|
|
// setThumbnail(streamingUrl);
|
|
// } else if (!shouldHide) {
|
|
// getFile(uri);
|
|
// }
|
|
// }
|
|
// }, [hasClaim, isFree, isImage, streamingUrl, uri, shouldHide]);
|
|
// @endif
|
|
|
|
const [thumbnail, setThumbnail] = React.useState(thumbnailToUse);
|
|
React.useEffect(() => {
|
|
setThumbnail(thumbnailToUse);
|
|
}, [thumbnailToUse]);
|
|
|
|
return thumbnail;
|
|
}
|