87c94e3c1c
* add mobile plugin back on ios * further touchups and fix ios * finish mobile functionality * dont show big play button on mobile * remove logs * proof of concept * dont go full screen on rotate * add back functionality * replace dispose event with navigate away * bugfix * turn off show if you liked button and nag only on homepage * add back old functionality * ending event not working * test here * working but needs cleanup * more player touchups * bugfix * add settings button on mobile * more touchups * more cleanups * touchup loading functionality * fix hover thumbnails * touchup and eslint fix * fix repopulation bug * change recsys event name * bugfix events * change the way buttons are removed and added * finish chapters button * refactor to use videojs methods * refactor to fix autoplay next * ux touchups * seems to be behaving properly * control bar behaving how it should * fix control bar on ios * working on flow and eslint errors * bugfix and flow fixes * bring back nudge * fix playlist button bug * remove chapter markers properly * show big play button * bugfix recsys closed event * fix analytics bug * fix embeds * bugfix * possible bugfix for kp * bugfix playlist buttons * fix issue with mobile ui plugin * fix firefox autoplay issue * fix bug for play on floating player closed * bugfix volume control for ios * instantiate new player if switching between claim types * fix flow and lint errors * fix control bar not showing up when switching sources * dispose old player if recreating * bugfix save position * reset recsys data between videos * fix audio upload posters * clear claimSrcVhs on reload * bugfix errant image previews showing up * reset player value of having already switched quality * fix watch position not being used * bugfix switching between sources not perserving position * fix save position bug * fix playlist buttons * bugfix * code cleanup and add back 5 second feature
167 lines
4.4 KiB
JavaScript
167 lines
4.4 KiB
JavaScript
// @flow
|
|
import * as REACTION_TYPES from 'constants/reactions';
|
|
import * as ICONS from 'constants/icons';
|
|
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import Button from 'component/button';
|
|
import RatioBar from 'component/ratioBar';
|
|
import { formatNumberWithCommas } from 'util/number';
|
|
import NudgeFloating from 'component/nudgeFloating';
|
|
// import Tooltip from 'component/common/tooltip';
|
|
|
|
const LIVE_REACTION_FETCH_MS = 1000 * 45;
|
|
|
|
type Props = {
|
|
uri: string,
|
|
// redux
|
|
claimId?: string,
|
|
channelTitle?: string,
|
|
isCollection?: boolean,
|
|
likeCount: number,
|
|
dislikeCount: number,
|
|
myReaction: ?string,
|
|
isLivestreamClaim?: boolean,
|
|
doFetchReactions: (claimId: ?string) => void,
|
|
doReactionLike: (uri: string) => void,
|
|
doReactionDislike: (uri: string) => void,
|
|
};
|
|
|
|
export default function FileReactions(props: Props) {
|
|
const {
|
|
uri,
|
|
claimId,
|
|
channelTitle,
|
|
isCollection,
|
|
myReaction,
|
|
likeCount,
|
|
dislikeCount,
|
|
isLivestreamClaim,
|
|
doFetchReactions,
|
|
doReactionLike,
|
|
doReactionDislike,
|
|
} = props;
|
|
|
|
const likeIcon = myReaction === REACTION_TYPES.LIKE ? ICONS.FIRE_ACTIVE : ICONS.FIRE;
|
|
const dislikeIcon = myReaction === REACTION_TYPES.DISLIKE ? ICONS.SLIME_ACTIVE : ICONS.SLIME;
|
|
|
|
const likeLabel = (
|
|
<>
|
|
{myReaction === REACTION_TYPES.LIKE && (
|
|
<>
|
|
<div className="button__fire-glow" />
|
|
<div className="button__fire-particle1" />
|
|
<div className="button__fire-particle2" />
|
|
<div className="button__fire-particle3" />
|
|
<div className="button__fire-particle4" />
|
|
<div className="button__fire-particle5" />
|
|
<div className="button__fire-particle6" />
|
|
</>
|
|
)}
|
|
{formatNumberWithCommas(likeCount, 0)}
|
|
</>
|
|
);
|
|
|
|
const dislikeLabel = (
|
|
<>
|
|
{myReaction === REACTION_TYPES.DISLIKE && (
|
|
<>
|
|
<div className="button__slime-stain" />
|
|
<div className="button__slime-drop1" />
|
|
<div className="button__slime-drop2" />
|
|
</>
|
|
)}
|
|
{formatNumberWithCommas(dislikeCount, 0)}
|
|
</>
|
|
);
|
|
|
|
React.useEffect(() => {
|
|
function fetchReactions() {
|
|
doFetchReactions(claimId);
|
|
}
|
|
|
|
let fetchInterval;
|
|
if (claimId) {
|
|
fetchReactions();
|
|
|
|
if (isLivestreamClaim) {
|
|
fetchInterval = setInterval(fetchReactions, LIVE_REACTION_FETCH_MS);
|
|
}
|
|
}
|
|
|
|
return () => {
|
|
if (fetchInterval) {
|
|
clearInterval(fetchInterval);
|
|
}
|
|
};
|
|
}, [claimId, doFetchReactions, isLivestreamClaim]);
|
|
|
|
return (
|
|
<>
|
|
{channelTitle && !isCollection && (
|
|
<NudgeFloating
|
|
name="nudge:support-acknowledge"
|
|
text={__('Let %channel% know you enjoyed this!', { channel: channelTitle })}
|
|
/>
|
|
)}
|
|
|
|
<div className={'ratio-wrapper'}>
|
|
<Button
|
|
title={__('I like this')}
|
|
requiresAuth={IS_WEB}
|
|
authSrc="filereaction_like"
|
|
className={classnames('button--file-action button-like', {
|
|
'button--fire': myReaction === REACTION_TYPES.LIKE,
|
|
})}
|
|
label={likeLabel}
|
|
iconSize={18}
|
|
icon={likeIcon}
|
|
onClick={() => doReactionLike(uri)}
|
|
/>
|
|
<Button
|
|
requiresAuth={IS_WEB}
|
|
authSrc={'filereaction_dislike'}
|
|
title={__('I dislike this')}
|
|
className={classnames('button--file-action button-dislike', {
|
|
'button--slime': myReaction === REACTION_TYPES.DISLIKE,
|
|
})}
|
|
label={dislikeLabel}
|
|
iconSize={18}
|
|
icon={dislikeIcon}
|
|
onClick={() => doReactionDislike(uri)}
|
|
/>
|
|
<RatioBar likeCount={likeCount} dislikeCount={dislikeCount} />
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
/*
|
|
type ReactionProps = {
|
|
title: string,
|
|
label: any,
|
|
icon: string,
|
|
isActive: boolean,
|
|
activeClassName: string,
|
|
onClick: () => void,
|
|
};
|
|
|
|
const FileReaction = (reactionProps: ReactionProps) => {
|
|
const { title, label, icon, isActive, activeClassName, onClick } = reactionProps;
|
|
|
|
return (
|
|
<Tooltip title={title} arrow={false}>
|
|
<div className="file-reaction__tooltip-inner">
|
|
<Button
|
|
requiresAuth
|
|
authSrc="filereaction_like"
|
|
className={classnames('button--file-action', { [activeClassName]: isActive })}
|
|
label={label}
|
|
iconSize={18}
|
|
icon={icon}
|
|
onClick={onClick}
|
|
/>
|
|
</div>
|
|
</Tooltip>
|
|
);
|
|
};
|
|
*/
|