lbry-desktop/ui/component/fileReactions/view.jsx

75 lines
2.2 KiB
React
Raw Normal View History

2020-10-02 21:18:53 +02:00
// @flow
2021-07-28 14:09:25 +02:00
import * as REACTION_TYPES from 'constants/reactions';
2020-10-02 21:18:53 +02:00
import * as ICONS from 'constants/icons';
import React from 'react';
import classnames from 'classnames';
import Button from 'component/button';
2022-04-26 17:28:23 +02:00
import { formatNumber } from 'util/number';
import NudgeFloating from 'component/nudgeFloating';
2020-10-02 21:18:53 +02:00
type Props = {
claim: StreamClaim,
wip 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
2021-02-06 08:03:51 +01:00
doFetchReactions: (string) => void,
doReactionLike: (string) => void,
doReactionDislike: (string) => void,
2020-10-02 21:18:53 +02:00
uri: string,
likeCount: number,
dislikeCount: number,
myReaction: ?string,
};
function FileReactions(props: Props) {
2022-04-26 17:28:23 +02:00
const { claim, uri, doFetchReactions, doReactionLike, doReactionDislike, myReaction, likeCount, dislikeCount } =
props;
2021-07-28 14:09:25 +02:00
2020-10-02 21:18:53 +02:00
const claimId = claim && claim.claim_id;
const channel = claim && claim.signing_channel && claim.signing_channel.name;
wip 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
2021-02-06 08:03:51 +01:00
const isCollection = claim && claim.value_type === 'collection'; // hack because nudge gets cut off by card on cols.
2021-10-19 01:37:58 +02:00
const likeIcon = ICONS.UPVOTE;
const dislikeIcon = ICONS.DOWNVOTE;
2020-10-02 21:18:53 +02:00
React.useEffect(() => {
2021-07-28 14:09:25 +02:00
function fetchReactions() {
2020-10-02 21:18:53 +02:00
doFetchReactions(claimId);
}
2021-07-28 14:09:25 +02:00
if (claimId) {
fetchReactions();
}
2021-10-19 06:49:51 +02:00
}, [claimId, doFetchReactions]);
2020-10-02 21:18:53 +02:00
return (
<>
wip 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
2021-02-06 08:03:51 +01:00
{channel && !isCollection && (
<NudgeFloating
name="nudge:support-acknowledge"
text={__('Let %channel% know you enjoyed this!', { channel })}
/>
)}
2020-10-02 21:18:53 +02:00
<Button
title={__('I like this')}
authSrc="filereaction_like"
className={classnames('button--file-action button-like', {
2021-10-19 01:37:58 +02:00
'button--file-action-active': myReaction === REACTION_TYPES.LIKE,
2021-10-16 22:24:52 +02:00
})}
2022-04-26 17:28:23 +02:00
label={<>{formatNumber(likeCount, 2, true)}</>}
2020-10-02 21:18:53 +02:00
iconSize={18}
2021-07-28 14:09:25 +02:00
icon={likeIcon}
2020-10-02 21:18:53 +02:00
onClick={() => doReactionLike(uri)}
/>
<Button
authSrc={'filereaction_dislike'}
2020-10-02 21:18:53 +02:00
title={__('I dislike this')}
className={classnames('button--file-action button-dislike', {
2021-10-19 06:49:51 +02:00
'button--file-action-active': myReaction === REACTION_TYPES.DISLIKE,
})}
2022-04-26 17:28:23 +02:00
label={<>{formatNumber(dislikeCount, 2, true)}</>}
2020-10-02 21:18:53 +02:00
iconSize={18}
2021-07-28 14:09:25 +02:00
icon={dislikeIcon}
2020-10-02 21:18:53 +02:00
onClick={() => doReactionDislike(uri)}
/>
</>
);
}
export default FileReactions;