lbry-desktop/ui/component/commentCreate/extra-contents.jsx
infinite-persistence a74dbe1e43 1075: Clamp comment channel-selector to commented channels only
## New behavior:
- If you have commented on a claim before, the channel selector will be clamped to that channel.
  - There might be more than 1 channel if commented in the past.
- This includes blocked comments, i.e. if the creator blocked you, you will not see your comment, yet your channel-selector is clamped to the used channel.
- EXCEPTION: you can use other channels if it's your own claim (for now).

## Approach
- Run `comment.List` over all your channels on the specific content. This covers nested replies and pagination (sweet).
  - So, if the total is non-zero, mark that channel(s) as having commented on the claim.
  - Only fetch this once per content claim.
- In the comment channel-selector, clamp the list to this value.
2022-05-02 16:07:00 -04:00

68 lines
2 KiB
JavaScript

// @flow
import 'scss/component/_comment-selectors.scss';
import React from 'react';
import * as ICONS from 'constants/icons';
import CreditAmount from 'component/common/credit-amount';
import I18nMessage from 'component/i18nMessage';
import Icon from 'component/common/icon';
import SelectChannel from 'component/selectChannel';
type SelectorProps = {
isReply: boolean,
isLivestream: boolean,
channelIds?: Array<string>, // Specific channel IDs to show. Must be a subset of own channels.
};
export const FormChannelSelector = (selectorProps: SelectorProps) => {
const { isReply, isLivestream, channelIds } = selectorProps;
return (
<div className="comment-create__label-wrapper">
<span className="comment-create__label">
{(isReply ? __('Replying as') : isLivestream ? __('Chat as') : __('Comment as')) + ' '}
</span>
<SelectChannel tiny channelIds={channelIds} />
</div>
);
};
type HelpTextProps = {
deletedComment: boolean,
minAmount: number,
minSuper: number,
minTip: number,
};
export const HelpText = (helpTextProps: HelpTextProps) => {
const { deletedComment, minAmount, minSuper, minTip } = helpTextProps;
return (
<>
{deletedComment && <div className="error__text">{__('This comment has been deleted.')}</div>}
{!!minAmount && (
<div className="help--notice comment-create__min-amount-notice">
<I18nMessage tokens={{ lbc: <CreditAmount noFormat amount={minAmount} /> }}>
{minTip ? 'Comment min: %lbc%' : minSuper ? 'HyperChat min: %lbc%' : ''}
</I18nMessage>
<Icon
customTooltipText={
minTip
? __('This channel requires a minimum tip for each comment.')
: minSuper
? __('This channel requires a minimum amount for HyperChats to be visible.')
: ''
}
className="icon--help"
icon={ICONS.HELP}
tooltip
size={16}
/>
</div>
)}
</>
);
};