fix target for notification for daily_watch_remind type

This commit is contained in:
Sean Yesmunt 2020-09-16 12:35:59 -04:00
parent c6e2b54d33
commit f8e01c7c99
2 changed files with 18 additions and 14 deletions

View file

@ -1,11 +1,6 @@
// @flow // @flow
import { import * as NOTIFICATIONS from 'constants/notifications';
NOTIFICATION_CREATOR_SUBSCRIBER,
NOTIFICATION_COMMENT,
NOTIFICATION_REPLY,
DAILY_WATCH_AVAILABLE,
} from 'constants/notifications';
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import React from 'react'; import React from 'react';
@ -31,12 +26,20 @@ export default function Notification(props: Props) {
const { notification, menuButton = false, doSeeNotifications } = props; const { notification, menuButton = false, doSeeNotifications } = 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 = const isCommentNotification =
notification && notification_rule === DAILY_WATCH_AVAILABLE notification_rule === NOTIFICATIONS.NOTIFICATION_COMMENT || notification_rule === NOTIFICATIONS.NOTIFICATION_REPLY;
? `/$/${PAGES.CHANNELS_FOLLOWING}`
: notification_parameters.device.target;
const isCommentNotification = notification_rule === NOTIFICATION_COMMENT || notification_rule === NOTIFICATION_REPLY;
const commentText = isCommentNotification && notification_parameters.dynamic.comment; const commentText = isCommentNotification && notification_parameters.dynamic.comment;
let notificationTarget;
switch (notification_rule) {
case NOTIFICATIONS.DAILY_WATCH_AVAILABLE:
case NOTIFICATIONS.DAILY_WATCH_REMIND:
notificationTarget = `/$/${PAGES.CHANNELS_FOLLOWING}`;
break;
default:
notificationTarget = notification_parameters.device.target;
}
let notificationLink = formatLbryUrlForWeb(notificationTarget); let notificationLink = formatLbryUrlForWeb(notificationTarget);
let urlParams = new URLSearchParams(); let urlParams = new URLSearchParams();
if (isCommentNotification && notification_parameters.dynamic.hash) { if (isCommentNotification && notification_parameters.dynamic.hash) {
@ -54,13 +57,13 @@ export default function Notification(props: Props) {
let icon; let icon;
switch (notification_rule) { switch (notification_rule) {
case NOTIFICATION_CREATOR_SUBSCRIBER: case NOTIFICATIONS.NOTIFICATION_CREATOR_SUBSCRIBER:
icon = <Icon icon={ICONS.SUBSCRIBE} sectionIcon className="notification__icon" />; icon = <Icon icon={ICONS.SUBSCRIBE} sectionIcon className="notification__icon" />;
break; break;
case NOTIFICATION_COMMENT: case NOTIFICATIONS.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: case NOTIFICATIONS.NOTIFICATION_REPLY:
icon = <ChannelThumbnail small uri={notification_parameters.dynamic.reply_author} />; icon = <ChannelThumbnail small uri={notification_parameters.dynamic.reply_author} />;
break; break;
default: default:

View file

@ -2,3 +2,4 @@ export const NOTIFICATION_CREATOR_SUBSCRIBER = 'creator_subscriber';
export const NOTIFICATION_COMMENT = 'comment'; export const NOTIFICATION_COMMENT = 'comment';
export const NOTIFICATION_REPLY = 'comment-reply'; export const NOTIFICATION_REPLY = 'comment-reply';
export const DAILY_WATCH_AVAILABLE = 'daily_watch_available'; export const DAILY_WATCH_AVAILABLE = 'daily_watch_available';
export const DAILY_WATCH_REMIND = 'daily_watch_remind';