2020-01-30 22:01:23 +01:00
|
|
|
// @flow
|
2021-03-17 21:53:35 +01:00
|
|
|
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
2021-12-22 17:12:44 +01:00
|
|
|
import React from 'react';
|
2020-01-30 22:01:23 +01:00
|
|
|
import UriIndicator from 'component/uriIndicator';
|
|
|
|
import DateTime from 'component/dateTime';
|
2021-12-22 17:12:44 +01:00
|
|
|
import LivestreamDateTime from 'component/livestreamDateTime';
|
2020-01-30 22:01:23 +01:00
|
|
|
import Button from 'component/button';
|
2021-09-09 09:02:31 +02:00
|
|
|
import FileViewCountInline from 'component/fileViewCountInline';
|
2022-02-26 15:55:49 +01:00
|
|
|
import { toCompactNotation } from 'util/string';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { parseURI } from 'util/lbryURI';
|
2020-01-30 22:01:23 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
2022-02-26 15:55:49 +01:00
|
|
|
type?: string,
|
|
|
|
showAtSign?: boolean,
|
|
|
|
// --- redux ---
|
2021-12-16 22:59:13 +01:00
|
|
|
claim: ?StreamClaim,
|
2020-01-30 22:01:23 +01:00
|
|
|
pending?: boolean,
|
2021-10-17 10:36:14 +02:00
|
|
|
beginPublish: (?string) => void,
|
2021-03-17 21:53:35 +01:00
|
|
|
isLivestream: boolean,
|
2022-02-26 15:55:49 +01:00
|
|
|
lang: string,
|
2021-10-16 20:12:09 +02:00
|
|
|
fetchSubCount: (string) => void,
|
|
|
|
subCount: number,
|
2022-03-09 19:05:37 +01:00
|
|
|
showMemberBadge?: boolean,
|
2020-01-30 22:01:23 +01:00
|
|
|
};
|
|
|
|
|
2021-09-29 21:04:43 +02:00
|
|
|
// previews used in channel overview and homepage (and other places?)
|
2020-01-30 23:25:15 +01:00
|
|
|
function ClaimPreviewSubtitle(props: Props) {
|
2022-03-09 19:05:37 +01:00
|
|
|
const {
|
|
|
|
pending,
|
|
|
|
uri,
|
|
|
|
claim,
|
|
|
|
type,
|
|
|
|
beginPublish,
|
|
|
|
isLivestream,
|
|
|
|
fetchSubCount,
|
|
|
|
subCount,
|
|
|
|
showAtSign,
|
|
|
|
lang,
|
|
|
|
showMemberBadge,
|
|
|
|
} = props;
|
2021-10-28 05:39:30 +02:00
|
|
|
const isChannel = claim && claim.value_type === 'channel';
|
2020-01-30 22:01:23 +01:00
|
|
|
const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
|
|
|
|
|
2021-10-16 20:12:09 +02:00
|
|
|
const claimId = (claim && claim.claim_id) || '0';
|
2022-02-26 15:55:49 +01:00
|
|
|
const formattedSubCount = toCompactNotation(subCount, lang, 10000);
|
2021-10-28 05:39:30 +02:00
|
|
|
|
2021-10-16 20:12:09 +02:00
|
|
|
React.useEffect(() => {
|
2021-10-28 05:39:30 +02:00
|
|
|
if (isChannel) {
|
|
|
|
fetchSubCount(claimId);
|
|
|
|
}
|
|
|
|
}, [isChannel, fetchSubCount, claimId]);
|
2021-10-16 20:12:09 +02:00
|
|
|
|
2020-01-30 22:01:23 +01:00
|
|
|
let name;
|
|
|
|
try {
|
2021-10-28 05:39:30 +02:00
|
|
|
({ streamName: name } = parseURI(uri));
|
2020-01-30 22:01:23 +01:00
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="media__subtitle">
|
|
|
|
{claim ? (
|
|
|
|
<React.Fragment>
|
2022-03-09 19:05:37 +01:00
|
|
|
<UriIndicator uri={uri} showAtSign={showAtSign} showMemberBadge={showMemberBadge} link />{' '}
|
2021-03-17 21:53:35 +01:00
|
|
|
{!pending && claim && (
|
|
|
|
<>
|
2021-10-16 20:12:09 +02:00
|
|
|
{isChannel && type !== 'inline' && (
|
|
|
|
<>
|
|
|
|
<span className="claim-preview-metadata-sub-upload">
|
2021-10-28 05:39:30 +02:00
|
|
|
{subCount === 1 ? __('1 Follower') : __('%formattedSubCount% Followers', { formattedSubCount })}
|
2021-10-16 20:12:09 +02:00
|
|
|
• {claimsInChannel} {claimsInChannel === 1 ? __('upload') : __('uploads')}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2021-03-17 21:53:35 +01:00
|
|
|
|
|
|
|
{!isChannel &&
|
2021-09-09 09:02:31 +02:00
|
|
|
(isLivestream && ENABLE_NO_SOURCE_CLAIMS ? (
|
2021-12-22 17:12:44 +01:00
|
|
|
<LivestreamDateTime uri={uri} />
|
2021-09-09 09:02:31 +02:00
|
|
|
) : (
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
<span className="claim-extra-info">
|
2021-09-09 09:02:31 +02:00
|
|
|
<FileViewCountInline uri={uri} isLivestream={isLivestream} />
|
|
|
|
<DateTime timeAgo uri={uri} />
|
Playlists v2: Refactors, touch ups + Queue Mode (#1604)
* Playlists v2
* Style pass
* Change playlist items arrange icon
* Playlist card body open by default
* Refactor collectionEdit components
* Paginate & Refactor bid field
* Collection page changes
* Add Thumbnail optional
* Replace extra info for description on collection page
* Playlist card right below video on medium screen
* Allow editing private collections
* Add edit option to menus
* Allow deleting a public playlist but keeping a private version
* Add queue to Save menu, remove edit option from Builtin pages, show queue on playlists page
* Fix scroll to recent persisting on medium screen
* Fix adding to queue from menu
* Fixes for delete
* PublishList: delay mounting Items tab to prevent lock-up (#1783)
For a large list, the playlist publish form is unusable (super-slow typing) due to the entire list being mounted despite the tab is not active.
The full solution is still to paginate it, but for now, don't mount the tab until it is selected. Add a spinner to indicate something is loading. It's not prefect, but it's throwaway code anyway. At least we can fill in the fields properly now.
* Batch-resolve private collections (#1782)
* makeSelectClaimForClaimId --> selectClaimForClaimId
Move away from the problematic `makeSelect*`, especially in large loops.
* Batch-resolve private collections
1758
This alleviates the lock-up that is caused by large number of invidual resolves. There will still be some minor stutter due to the large DOM that React needs to handle -- that is logged in 1758 and will be handled separately.
At least the stutter is short (1-2s) and the app is still usable.
Private list items are being resolve individually, super slow if the list is large (>100). Published lists doesn't have this issue.
doFetchItemsInCollections contains most of the useful logic, but it isn't called for private/built-in lists because it's not an actual claim.
Tweaked doFetchItemsInCollections to handle private (UUID-based) collections.
* Use persisted state for floating player playlist card body
- I find it annoying being open everytime
* Fix removing edits from published playlist
* Fix scroll on mobile
* Allow going editing items from toast
* Fix ClaimShareButton
* Prevent edit/publish of builtin
* Fix async inside forEach
* Fix sync on queue edit
* Fix autoplayCountdown replay
* Fix deleting an item scrolling the playlist
* CreatedAt fixes
* Remove repost for now
* Anon publish fixes
* Fix mature case on floating
Co-authored-by: infinite-persistence <64950861+infinite-persistence@users.noreply.github.com>
2022-07-13 15:59:59 +02:00
|
|
|
</span>
|
2021-09-09 09:02:31 +02:00
|
|
|
))}
|
2021-03-17 21:53:35 +01:00
|
|
|
</>
|
|
|
|
)}
|
2020-01-30 22:01:23 +01:00
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
<React.Fragment>
|
2020-07-23 19:02:07 +02:00
|
|
|
<div>{__('Upload something and claim this spot!')}</div>
|
2020-01-30 22:01:23 +01:00
|
|
|
<div className="card__actions">
|
|
|
|
<Button onClick={() => beginPublish(name)} button="primary" label={__('Publish to %uri%', { uri })} />
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-01-30 23:25:15 +01:00
|
|
|
export default ClaimPreviewSubtitle;
|