2020-07-13 14:57:03 +02:00
|
|
|
// @flow
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import * as React from 'react';
|
|
|
|
import DateTime from 'component/dateTime';
|
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
import { Lbryio } from 'lbryinc';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
channelClaimId: string,
|
|
|
|
includeSyncDate: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function YoutubeBadge(props: Props) {
|
|
|
|
const { channelClaimId, includeSyncDate = true } = props;
|
|
|
|
|
|
|
|
const [isVerified, setIsVerified] = React.useState();
|
|
|
|
const [lastYtSyncDate, setLastYtSyncDate] = React.useState();
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (channelClaimId) {
|
|
|
|
Lbryio.call('yt', 'get_youtuber', { channel_claim_id: channelClaimId }).then(response => {
|
|
|
|
if (response.is_verified_youtuber) {
|
|
|
|
setIsVerified(true);
|
|
|
|
setLastYtSyncDate(response.last_synced);
|
|
|
|
} else {
|
|
|
|
setIsVerified(false);
|
|
|
|
setLastYtSyncDate(undefined);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setIsVerified(false);
|
|
|
|
setLastYtSyncDate(undefined);
|
|
|
|
}
|
|
|
|
}, [channelClaimId]);
|
|
|
|
|
|
|
|
if (isVerified) {
|
|
|
|
const str =
|
|
|
|
includeSyncDate && lastYtSyncDate
|
2020-07-15 21:34:22 +02:00
|
|
|
? __('Official YouTube Creator - Last checked %time_ago%', { time_ago: DateTime.getTimeAgoStr(lastYtSyncDate) })
|
2020-07-13 14:57:03 +02:00
|
|
|
: __('Official YouTube Creator');
|
|
|
|
return (
|
2020-07-16 03:59:52 +02:00
|
|
|
<div className="media__uri--right--yt-badge">
|
2020-07-13 14:57:03 +02:00
|
|
|
<Icon icon={ICONS.VALIDATED} size={12} />
|
|
|
|
{str}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|