From ec6a2c315b32d122e29a24e8f5c037cf43f469e3 Mon Sep 17 00:00:00 2001 From: saltrafael Date: Tue, 27 Jul 2021 14:01:52 -0300 Subject: [PATCH] Allow to react/reply to comments from notifications --- ui/component/notification/view.jsx | 133 +++++++++++++++++---------- ui/scss/component/_notification.scss | 13 +++ 2 files changed, 99 insertions(+), 47 deletions(-) diff --git a/ui/component/notification/view.jsx b/ui/component/notification/view.jsx index 84e20fb17..083e033ed 100644 --- a/ui/component/notification/view.jsx +++ b/ui/component/notification/view.jsx @@ -9,6 +9,7 @@ import DateTime from 'component/dateTime'; import Button from 'component/button'; import ChannelThumbnail from 'component/channelThumbnail'; import { formatLbryUrlForWeb } from 'util/url'; +import { useHistory } from 'react-router'; import { parseURI } from 'lbry-redux'; import { PAGE_VIEW_QUERY, DISCUSSION_PAGE } from 'page/channel/view'; import FileThumbnail from 'component/fileThumbnail'; @@ -17,6 +18,8 @@ import NotificationContentChannelMenu from 'component/notificationContentChannel import LbcMessage from 'component/common/lbc-message'; import { NavLink } from 'react-router-dom'; import UriIndicator from 'component/uriIndicator'; +import CommentReactions from 'component/commentReactions'; +// import CommentCreate from 'component/commentCreate'; type Props = { notification: WebNotification, @@ -28,7 +31,9 @@ type Props = { export default function Notification(props: Props) { const { notification, menuButton = false, doReadNotifications, doDeleteNotification } = props; + const { push } = useHistory(); const { notification_rule, notification_parameters, is_read, id } = notification; + const [isReplying, setReplying] = React.useState(false); const isCommentNotification = notification_rule === RULE.COMMENT || notification_rule === RULE.COMMENT_REPLY || @@ -127,6 +132,10 @@ export default function Notification(props: Props) { if (!is_read) { doReadNotifications([id]); } + + if (notificationLink) { + push(notificationLink); + } } function handleReadNotification(e) { @@ -134,6 +143,10 @@ export default function Notification(props: Props) { doReadNotifications([id]); } + function handleCommentReply() { + setReplying(!isReplying); + } + const Wrapper = menuButton ? (props: { children: any }) => ( @@ -156,18 +169,20 @@ export default function Notification(props: Props) { ); return ( - - -
+ +
+
{icon}
+
-
-
-
+
+
+
+ {!isCommentNotification && (
{title}
)} @@ -189,50 +204,74 @@ export default function Notification(props: Props) {
)} -
+ - {notification_rule === RULE.NEW_CONTENT && ( - - )} - {notification_rule === RULE.NEW_LIVESTREAM && ( - + {isCommentNotification && ( +
+
)}
-
- {!is_read &&
+ {notification_rule === RULE.NEW_CONTENT && ( + + )} + {notification_rule === RULE.NEW_LIVESTREAM && ( + + )}
-
- - { - e.preventDefault(); - e.stopPropagation(); - }}> - - - - doDeleteNotification(id)}> - - {__('Delete')} - - {notification_rule === RULE.NEW_CONTENT && channelUrl ? ( - - ) : null} - - +
+ {!is_read &&
- - + +
+ + { + e.preventDefault(); + e.stopPropagation(); + }}> + + + + doDeleteNotification(id)}> + + {__('Delete')} + + {notification_rule === RULE.NEW_CONTENT && channelUrl ? ( + + ) : null} + + +
+
+ ); } diff --git a/ui/scss/component/_notification.scss b/ui/scss/component/_notification.scss index 6d61abba5..fb291bb4b 100644 --- a/ui/scss/component/_notification.scss +++ b/ui/scss/component/_notification.scss @@ -162,6 +162,19 @@ $contentMaxWidth: 60rem; } } +.notification__reactions { + display: flex; + margin-top: var(--spacing-s); + + > *:not(:last-of-type) { + margin-right: var(--spacing-m); + } + + .button__label { + margin-left: var(--spacing-xs); + } +} + .notification__bubble { height: 1.5rem; width: 1.5rem;