mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-30 08:51:24 +00:00
do not set comment channel anonymous, (#3787)
set to top channel if not already persisted
This commit is contained in:
parent
15416487e7
commit
e87fabe55a
2 changed files with 19 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doCommentCreate, makeSelectClaimForUri } from 'lbry-redux';
|
import { doCommentCreate, makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import { CommentCreate } from './view';
|
import { CommentCreate } from './view';
|
||||||
import { selectUserVerifiedEmail } from 'lbryinc';
|
import { selectUserVerifiedEmail } from 'lbryinc';
|
||||||
|
@ -7,6 +7,7 @@ import { selectUserVerifiedEmail } from 'lbryinc';
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
|
channels: selectMyChannelClaims(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -14,16 +14,32 @@ type Props = {
|
||||||
claim: StreamClaim,
|
claim: StreamClaim,
|
||||||
openModal: (id: string, { onCommentAcknowledge: () => void }) => void,
|
openModal: (id: string, { onCommentAcknowledge: () => void }) => void,
|
||||||
createComment: (string, string, string) => void,
|
createComment: (string, string, string) => void,
|
||||||
|
channels: ?Array<ChannelClaim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function CommentCreate(props: Props) {
|
export function CommentCreate(props: Props) {
|
||||||
const { commentingEnabled, createComment, claim, openModal } = props;
|
const { commentingEnabled, createComment, claim, openModal, channels } = props;
|
||||||
const { claim_id: claimId } = claim;
|
const { claim_id: claimId } = claim;
|
||||||
const [commentValue, setCommentValue] = usePersistedState(`comment-${claimId}`, '');
|
const [commentValue, setCommentValue] = usePersistedState(`comment-${claimId}`, '');
|
||||||
const [commentAck, setCommentAck] = usePersistedState('comment-acknowledge', false);
|
const [commentAck, setCommentAck] = usePersistedState('comment-acknowledge', false);
|
||||||
const [channel, setChannel] = usePersistedState('comment-channel', '');
|
const [channel, setChannel] = usePersistedState('comment-channel', '');
|
||||||
const [charCount, setCharCount] = useState(commentValue.length);
|
const [charCount, setCharCount] = useState(commentValue.length);
|
||||||
|
|
||||||
|
const topChannel =
|
||||||
|
channels &&
|
||||||
|
channels.reduce((top, channel) => {
|
||||||
|
const topClaimCount = (top && top.meta && top.meta.claims_in_channel) || 0;
|
||||||
|
const currentClaimCount = (channel && channel.meta && channel.meta.claims_in_channel) || 0;
|
||||||
|
return topClaimCount >= currentClaimCount ? top : channel;
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// set default channel
|
||||||
|
if ((channel === '' || channel === 'anonymous') && topChannel) {
|
||||||
|
handleChannelChange(topChannel.name);
|
||||||
|
}
|
||||||
|
}, [channel, topChannel]);
|
||||||
|
|
||||||
function handleCommentChange(event) {
|
function handleCommentChange(event) {
|
||||||
setCommentValue(event.target.value);
|
setCommentValue(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue