2020-07-13 14:57:03 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2022-01-03 13:41:00 +01:00
|
|
|
import { getTimeAgoStr } from 'util/time';
|
2020-07-13 14:57:03 +02:00
|
|
|
import { Lbryio } from 'lbryinc';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
channelClaimId: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function YoutubeBadge(props: Props) {
|
2020-10-06 22:28:12 +02:00
|
|
|
const { channelClaimId } = props;
|
2020-07-13 14:57:03 +02:00
|
|
|
const [isVerified, setIsVerified] = React.useState();
|
|
|
|
const [lastYtSyncDate, setLastYtSyncDate] = React.useState();
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (channelClaimId) {
|
2022-01-03 13:41:00 +01:00
|
|
|
Lbryio.call('yt', 'get_youtuber', { channel_claim_id: channelClaimId }).then((response) => {
|
2020-07-13 14:57:03 +02:00
|
|
|
if (response.is_verified_youtuber) {
|
|
|
|
setIsVerified(true);
|
|
|
|
setLastYtSyncDate(response.last_synced);
|
|
|
|
} else {
|
|
|
|
setIsVerified(false);
|
|
|
|
setLastYtSyncDate(undefined);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setIsVerified(false);
|
|
|
|
setLastYtSyncDate(undefined);
|
|
|
|
}
|
|
|
|
}, [channelClaimId]);
|
|
|
|
|
|
|
|
if (isVerified) {
|
|
|
|
return (
|
2020-10-06 22:28:12 +02:00
|
|
|
<>
|
|
|
|
<label>{__('Official YouTube Creator')}</label>
|
|
|
|
<div className="media__info-text">
|
|
|
|
<div className="media__info-text media__info-text--constrained">
|
2022-01-03 13:41:00 +01:00
|
|
|
{lastYtSyncDate && __('Last checked %time_ago%', { time_ago: getTimeAgoStr(lastYtSyncDate) })}
|
2020-10-06 22:28:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
2020-07-13 14:57:03 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|