handle comment reply notifications
This commit is contained in:
parent
b3d8a82897
commit
86003c73a3
3 changed files with 11 additions and 5 deletions
1
flow-typed/notification.js
vendored
1
flow-typed/notification.js
vendored
|
@ -22,6 +22,7 @@ declare type WebNotification = {
|
||||||
},
|
},
|
||||||
dynamic: {
|
dynamic: {
|
||||||
comment_author: string,
|
comment_author: string,
|
||||||
|
reply_author: string,
|
||||||
hash: string,
|
hash: string,
|
||||||
claim_title: string,
|
claim_title: string,
|
||||||
comment?: string,
|
comment?: string,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { NOTIFICATION_CREATOR_SUBSCRIBER, NOTIFICATION_COMMENT } from 'constants/notifications';
|
import { NOTIFICATION_CREATOR_SUBSCRIBER, NOTIFICATION_COMMENT, NOTIFICATION_REPLY } from 'constants/notifications';
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
@ -26,10 +26,11 @@ export default function Notification(props: Props) {
|
||||||
const { push } = useHistory();
|
const { push } = useHistory();
|
||||||
const { notification_rule, notification_parameters, is_seen, id } = notification;
|
const { notification_rule, notification_parameters, is_seen, id } = notification;
|
||||||
const notificationTarget = notification && notification_parameters.device.target;
|
const notificationTarget = notification && notification_parameters.device.target;
|
||||||
const commentText = notification_rule === NOTIFICATION_COMMENT && notification_parameters.dynamic.comment;
|
const isCommentNotification = notification_rule === NOTIFICATION_COMMENT || notification_rule === NOTIFICATION_REPLY;
|
||||||
|
const commentText = isCommentNotification && notification_parameters.dynamic.comment;
|
||||||
let notificationLink = formatLbryUrlForWeb(notificationTarget);
|
let notificationLink = formatLbryUrlForWeb(notificationTarget);
|
||||||
let urlParams = new URLSearchParams();
|
let urlParams = new URLSearchParams();
|
||||||
if (notification_rule === NOTIFICATION_COMMENT && notification_parameters.dynamic.hash) {
|
if (isCommentNotification && notification_parameters.dynamic.hash) {
|
||||||
urlParams.append('lc', notification_parameters.dynamic.hash);
|
urlParams.append('lc', notification_parameters.dynamic.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,9 @@ export default function Notification(props: Props) {
|
||||||
case NOTIFICATION_COMMENT:
|
case NOTIFICATION_COMMENT:
|
||||||
icon = <ChannelThumbnail small uri={notification_parameters.dynamic.comment_author} />;
|
icon = <ChannelThumbnail small uri={notification_parameters.dynamic.comment_author} />;
|
||||||
break;
|
break;
|
||||||
|
case NOTIFICATION_REPLY:
|
||||||
|
icon = <ChannelThumbnail small uri={notification_parameters.dynamic.reply_author} />;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
icon = <Icon icon={ICONS.NOTIFICATION} sectionIcon className="notification__icon" />;
|
icon = <Icon icon={ICONS.NOTIFICATION} sectionIcon className="notification__icon" />;
|
||||||
}
|
}
|
||||||
|
@ -100,11 +104,11 @@ export default function Notification(props: Props) {
|
||||||
<div className="notification__icon">{icon}</div>
|
<div className="notification__icon">{icon}</div>
|
||||||
<div className="notification__content">
|
<div className="notification__content">
|
||||||
<div>
|
<div>
|
||||||
{notification_rule !== NOTIFICATION_COMMENT && (
|
{!isCommentNotification && (
|
||||||
<div className="notification__title">{notification_parameters.device.title}</div>
|
<div className="notification__title">{notification_parameters.device.title}</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{notification_rule === NOTIFICATION_COMMENT && commentText ? (
|
{isCommentNotification && commentText ? (
|
||||||
<>
|
<>
|
||||||
<div className="notification__title">{notification_parameters.device.title}</div>
|
<div className="notification__title">{notification_parameters.device.title}</div>
|
||||||
<div className="notification__text mobile-hidden">{commentText}</div>
|
<div className="notification__text mobile-hidden">{commentText}</div>
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export const NOTIFICATION_CREATOR_SUBSCRIBER = 'creator_subscriber';
|
export const NOTIFICATION_CREATOR_SUBSCRIBER = 'creator_subscriber';
|
||||||
export const NOTIFICATION_COMMENT = 'comment';
|
export const NOTIFICATION_COMMENT = 'comment';
|
||||||
|
export const NOTIFICATION_REPLY = 'comment-reply';
|
||||||
|
|
Loading…
Add table
Reference in a new issue