mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
Show reply and fix clickability of menu options/emojis
This commit is contained in:
parent
076df9c47f
commit
985f8e3724
8 changed files with 87 additions and 17 deletions
|
@ -59,7 +59,9 @@ type Props = {
|
||||||
stakedLevel: number,
|
stakedLevel: number,
|
||||||
supportAmount: number,
|
supportAmount: number,
|
||||||
numDirectReplies: number,
|
numDirectReplies: number,
|
||||||
isFiat: boolean
|
isFiat: boolean,
|
||||||
|
setCommentReply: (any) => void,
|
||||||
|
commentReply: any,
|
||||||
};
|
};
|
||||||
|
|
||||||
const LENGTH_TO_COLLAPSE = 300;
|
const LENGTH_TO_COLLAPSE = 300;
|
||||||
|
@ -93,6 +95,8 @@ function Comment(props: Props) {
|
||||||
supportAmount,
|
supportAmount,
|
||||||
numDirectReplies,
|
numDirectReplies,
|
||||||
isFiat,
|
isFiat,
|
||||||
|
setCommentReply,
|
||||||
|
commentReply,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -178,6 +182,7 @@ function Comment(props: Props) {
|
||||||
|
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
updateComment(commentId, editedMessage);
|
updateComment(commentId, editedMessage);
|
||||||
|
setCommentReply({ ...commentReply, comment_id: commentId, comment: editedMessage });
|
||||||
setEditing(false);
|
setEditing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +258,10 @@ function Comment(props: Props) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="comment__menu">
|
<span className="comment__menu" onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}}>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuButton className="menu__button">
|
<MenuButton className="menu__button">
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -271,9 +279,10 @@ function Comment(props: Props) {
|
||||||
commentIsMine={commentIsMine}
|
commentIsMine={commentIsMine}
|
||||||
handleEditComment={handleEditComment}
|
handleEditComment={handleEditComment}
|
||||||
supportAmount={supportAmount}
|
supportAmount={supportAmount}
|
||||||
|
setCommentReply={setCommentReply}
|
||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
|
@ -286,6 +295,10 @@ function Comment(props: Props) {
|
||||||
charCount={charCount}
|
charCount={charCount}
|
||||||
onChange={handleEditMessageChanged}
|
onChange={handleEditMessageChanged}
|
||||||
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
|
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="section__actions section__actions--no-margin">
|
<div className="section__actions section__actions--no-margin">
|
||||||
<Button
|
<Button
|
||||||
|
@ -294,8 +307,15 @@ function Comment(props: Props) {
|
||||||
label={__('Done')}
|
label={__('Done')}
|
||||||
requiresAuth={IS_WEB}
|
requiresAuth={IS_WEB}
|
||||||
disabled={message === editedMessage}
|
disabled={message === editedMessage}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Button button="link" label={__('Cancel')} onClick={() => setEditing(false)} />
|
<Button button="link" label={__('Cancel')} onClick={(e) => {
|
||||||
|
setEditing(false);
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}} />
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
) : (
|
) : (
|
||||||
|
@ -330,7 +350,11 @@ function Comment(props: Props) {
|
||||||
requiresAuth={IS_WEB}
|
requiresAuth={IS_WEB}
|
||||||
label={commentingEnabled ? __('Reply') : __('Log in to reply')}
|
label={commentingEnabled ? __('Reply') : __('Log in to reply')}
|
||||||
className="comment__action"
|
className="comment__action"
|
||||||
onClick={handleCommentReply}
|
onClick={(e) => {
|
||||||
|
handleCommentReply();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
icon={ICONS.REPLY}
|
icon={ICONS.REPLY}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -50,6 +50,7 @@ type Props = {
|
||||||
sendTip: ({}, (any) => void, (any) => void) => void,
|
sendTip: ({}, (any) => void, (any) => void) => void,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
|
setCommentReply: (any) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function CommentCreate(props: Props) {
|
export function CommentCreate(props: Props) {
|
||||||
|
@ -71,6 +72,7 @@ export function CommentCreate(props: Props) {
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
sendTip,
|
sendTip,
|
||||||
doToast,
|
doToast,
|
||||||
|
setCommentReply,
|
||||||
} = props;
|
} = props;
|
||||||
const buttonRef: ElementRef<any> = React.useRef();
|
const buttonRef: ElementRef<any> = React.useRef();
|
||||||
const {
|
const {
|
||||||
|
@ -244,6 +246,7 @@ export function CommentCreate(props: Props) {
|
||||||
createComment(commentValue, claimId, parentId, txid, payment_intent_id, environment)
|
createComment(commentValue, claimId, parentId, txid, payment_intent_id, environment)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
|
setCommentReply(res);
|
||||||
|
|
||||||
if (res && res.signature) {
|
if (res && res.signature) {
|
||||||
setCommentValue('');
|
setCommentValue('');
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Props = {
|
||||||
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||||
openModal: (id: string, {}) => void,
|
openModal: (id: string, {}) => void,
|
||||||
supportAmount?: any,
|
supportAmount?: any,
|
||||||
|
setCommentReply: (any) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function CommentMenuList(props: Props) {
|
function CommentMenuList(props: Props) {
|
||||||
|
@ -56,6 +57,7 @@ function CommentMenuList(props: Props) {
|
||||||
moderationDelegatorsById,
|
moderationDelegatorsById,
|
||||||
openModal,
|
openModal,
|
||||||
supportAmount,
|
supportAmount,
|
||||||
|
setCommentReply,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const contentChannelClaim = !claim
|
const contentChannelClaim = !claim
|
||||||
|
@ -83,7 +85,7 @@ function CommentMenuList(props: Props) {
|
||||||
if (playingUri && playingUri.source === 'comment') {
|
if (playingUri && playingUri.source === 'comment') {
|
||||||
clearPlayingUri();
|
clearPlayingUri();
|
||||||
}
|
}
|
||||||
openModal(MODALS.CONFIRM_REMOVE_COMMENT, { commentId, commentIsMine, contentChannelPermanentUrl, supportAmount });
|
openModal(MODALS.CONFIRM_REMOVE_COMMENT, { commentId, commentIsMine, contentChannelPermanentUrl, supportAmount, setCommentReply });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCommentBlock() {
|
function handleCommentBlock() {
|
||||||
|
|
|
@ -283,10 +283,12 @@ export class FormField extends React.PureComponent<Props> {
|
||||||
type="button"
|
type="button"
|
||||||
className="button--emoji"
|
className="button--emoji"
|
||||||
label={emoji}
|
label={emoji}
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
inputProps.onChange({
|
inputProps.onChange({
|
||||||
target: { value: inputProps.value ? `${inputProps.value} ${emoji}` : emoji },
|
target: { value: inputProps.value ? `${inputProps.value} ${emoji}` : emoji },
|
||||||
});
|
});
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doReadNotifications, doDeleteNotification } from 'redux/actions/notifications';
|
import { doReadNotifications, doDeleteNotification } from 'redux/actions/notifications';
|
||||||
import { doResolveUri } from 'lbry-redux';
|
import { doResolveUri, selectMyChannelClaims } from 'lbry-redux';
|
||||||
import Notification from './view';
|
import Notification from './view';
|
||||||
|
|
||||||
export default connect(null, {
|
const select = (state) => ({
|
||||||
|
myChannels: selectMyChannelClaims(state),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(select, {
|
||||||
doReadNotifications,
|
doReadNotifications,
|
||||||
doDeleteNotification,
|
doDeleteNotification,
|
||||||
doResolveUri,
|
doResolveUri,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import LbcMessage from 'component/common/lbc-message';
|
||||||
import UriIndicator from 'component/uriIndicator';
|
import UriIndicator from 'component/uriIndicator';
|
||||||
import CommentReactions from 'component/commentReactions';
|
import CommentReactions from 'component/commentReactions';
|
||||||
import CommentCreate from 'component/commentCreate';
|
import CommentCreate from 'component/commentCreate';
|
||||||
|
import CommentView from 'component/comment';
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -28,13 +29,27 @@ type Props = {
|
||||||
doReadNotifications: ([number]) => void,
|
doReadNotifications: ([number]) => void,
|
||||||
doDeleteNotification: (number) => void,
|
doDeleteNotification: (number) => void,
|
||||||
doResolveUri: (string) => void,
|
doResolveUri: (string) => void,
|
||||||
|
myChannels: ?Array<ChannelClaim>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Notification(props: Props) {
|
export default function Notification(props: Props) {
|
||||||
const { notification, menuButton = false, doReadNotifications, doDeleteNotification, doResolveUri } = props;
|
const { notification, menuButton = false, doReadNotifications, doDeleteNotification, doResolveUri, myChannels } = props;
|
||||||
const { push } = useHistory();
|
const { push } = useHistory();
|
||||||
const { notification_rule, notification_parameters, is_read, id } = notification;
|
const { notification_rule, notification_parameters, is_read, id } = notification;
|
||||||
const [isReplying, setReplying] = React.useState(false);
|
const [isReplying, setReplying] = React.useState(false);
|
||||||
|
const [commentReply, setCommentReply] = React.useState();
|
||||||
|
|
||||||
|
const isMyComment = (channelId: string): boolean => {
|
||||||
|
if (myChannels != null && channelId != null) {
|
||||||
|
for (let i = 0; i < myChannels.length; i++) {
|
||||||
|
if (myChannels[i].claim_id === channelId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const isCommentNotification =
|
const isCommentNotification =
|
||||||
notification_rule === RULE.COMMENT ||
|
notification_rule === RULE.COMMENT ||
|
||||||
notification_rule === RULE.COMMENT_REPLY ||
|
notification_rule === RULE.COMMENT_REPLY ||
|
||||||
|
@ -246,12 +261,29 @@ export default function Notification(props: Props) {
|
||||||
isReply
|
isReply
|
||||||
uri={notificationTarget}
|
uri={notificationTarget}
|
||||||
parentId={notification_parameters.dynamic.hash}
|
parentId={notification_parameters.dynamic.hash}
|
||||||
onDoneReplying={() => {
|
onDoneReplying={() => setReplying(false)}
|
||||||
setReplying(false);
|
onCancelReplying={() => setReplying(false)}
|
||||||
}}
|
setCommentReply={setCommentReply}
|
||||||
onCancelReplying={() => {
|
/>
|
||||||
setReplying(false);
|
)}
|
||||||
}}
|
|
||||||
|
{commentReply && (
|
||||||
|
<CommentView
|
||||||
|
key={commentReply.comment_id}
|
||||||
|
uri={notificationTarget}
|
||||||
|
authorUri={commentReply.channel_url}
|
||||||
|
author={commentReply.channel_name}
|
||||||
|
claimId={commentReply.claim_id}
|
||||||
|
commentId={commentReply.comment_id}
|
||||||
|
message={commentReply.comment}
|
||||||
|
timePosted={commentReply.timestamp * 1000}
|
||||||
|
commentIsMine={commentReply.channel_id && isMyComment(commentReply.channel_id)}
|
||||||
|
isPinned={commentReply.is_pinned}
|
||||||
|
supportAmount={commentReply.support_amount}
|
||||||
|
numDirectReplies={commentReply.replies}
|
||||||
|
isFiat={commentReply.is_fiat}
|
||||||
|
setCommentReply={setCommentReply}
|
||||||
|
commentReply={commentReply}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -11,10 +11,11 @@ type Props = {
|
||||||
closeModal: () => void,
|
closeModal: () => void,
|
||||||
deleteComment: (string, ?string) => void,
|
deleteComment: (string, ?string) => void,
|
||||||
supportAmount?: any,
|
supportAmount?: any,
|
||||||
|
setCommentReply: (any) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ModalRemoveComment(props: Props) {
|
function ModalRemoveComment(props: Props) {
|
||||||
const { commentId, commentIsMine, contentChannelPermanentUrl, closeModal, deleteComment, supportAmount } = props;
|
const { commentId, commentIsMine, contentChannelPermanentUrl, closeModal, deleteComment, supportAmount, setCommentReply } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen contentLabel={__('Confirm Comment Deletion')} type="card" onAborted={closeModal}>
|
<Modal isOpen contentLabel={__('Confirm Comment Deletion')} type="card" onAborted={closeModal}>
|
||||||
|
@ -36,6 +37,7 @@ function ModalRemoveComment(props: Props) {
|
||||||
label={__('Remove')}
|
label={__('Remove')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl);
|
deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl);
|
||||||
|
setCommentReply(undefined);
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -218,6 +218,7 @@ $thumbnailWidthSmall: 1rem;
|
||||||
.comment__message {
|
.comment__message {
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
max-width: 35rem;
|
max-width: 35rem;
|
||||||
|
color: var(--color-text);
|
||||||
|
|
||||||
ul li,
|
ul li,
|
||||||
ol li {
|
ol li {
|
||||||
|
|
Loading…
Add table
Reference in a new issue