mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
Fix title
This commit is contained in:
parent
4e02c84f90
commit
3df47c607c
1 changed files with 47 additions and 53 deletions
|
@ -39,8 +39,6 @@ export default function Notification(props: Props) {
|
||||||
notification_rule === RULE.COMMENT_REPLY ||
|
notification_rule === RULE.COMMENT_REPLY ||
|
||||||
notification_rule === RULE.CREATOR_COMMENT;
|
notification_rule === RULE.CREATOR_COMMENT;
|
||||||
const commentText = isCommentNotification && notification_parameters.dynamic.comment;
|
const commentText = isCommentNotification && notification_parameters.dynamic.comment;
|
||||||
const channelUrl =
|
|
||||||
(notification_rule === RULE.NEW_CONTENT && notification.notification_parameters.dynamic.channel_url) || '';
|
|
||||||
|
|
||||||
let notificationTarget;
|
let notificationTarget;
|
||||||
switch (notification_rule) {
|
switch (notification_rule) {
|
||||||
|
@ -56,24 +54,63 @@ export default function Notification(props: Props) {
|
||||||
notificationTarget = notification_parameters.device.target;
|
notificationTarget = notification_parameters.device.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const creatorIcon = (channelUrl) => {
|
||||||
|
return (
|
||||||
|
<UriIndicator uri={channelUrl} link>
|
||||||
|
<ChannelThumbnail small uri={channelUrl} />
|
||||||
|
</UriIndicator>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
let channelUrl;
|
||||||
|
let icon;
|
||||||
|
switch (notification_rule) {
|
||||||
|
case RULE.CREATOR_SUBSCRIBER:
|
||||||
|
icon = <Icon icon={ICONS.SUBSCRIBE} sectionIcon />;
|
||||||
|
break;
|
||||||
|
case RULE.COMMENT:
|
||||||
|
case RULE.CREATOR_COMMENT:
|
||||||
|
channelUrl = notification_parameters.dynamic.comment_author;
|
||||||
|
icon = creatorIcon(channelUrl);
|
||||||
|
break;
|
||||||
|
case RULE.COMMENT_REPLY:
|
||||||
|
channelUrl = notification_parameters.dynamic.reply_author;
|
||||||
|
icon = creatorIcon(channelUrl);
|
||||||
|
break;
|
||||||
|
case RULE.NEW_CONTENT:
|
||||||
|
channelUrl = notification_parameters.dynamic.channel_url;
|
||||||
|
icon = creatorIcon(channelUrl);
|
||||||
|
break;
|
||||||
|
case RULE.NEW_LIVESTREAM:
|
||||||
|
channelUrl = notification_parameters.dynamic.channel_url;
|
||||||
|
icon = creatorIcon(channelUrl);
|
||||||
|
break;
|
||||||
|
case RULE.DAILY_WATCH_AVAILABLE:
|
||||||
|
case RULE.DAILY_WATCH_REMIND:
|
||||||
|
case RULE.MISSED_OUT:
|
||||||
|
case RULE.REWARDS_APPROVAL_PROMPT:
|
||||||
|
icon = <Icon icon={ICONS.LBC} sectionIcon />;
|
||||||
|
break;
|
||||||
|
case RULE.FIAT_TIP:
|
||||||
|
icon = <Icon icon={ICONS.FINANCE} sectionIcon />;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
icon = <Icon icon={ICONS.NOTIFICATION} sectionIcon />;
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
urlParams.append('lc', notification_parameters.dynamic.hash);
|
urlParams.append('lc', notification_parameters.dynamic.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let channelName = channelUrl && ('@' + channelUrl.split('@')[1].split('#')[0]);
|
||||||
|
|
||||||
const notificationTitle = notification_parameters.device.title;
|
const notificationTitle = notification_parameters.device.title;
|
||||||
const titleSplit = notificationTitle.split(' ');
|
const titleSplit = notificationTitle.split(' ');
|
||||||
let creatorName;
|
|
||||||
titleSplit.map((s) => {
|
|
||||||
if (!creatorName && s.includes('@')) {
|
|
||||||
creatorName = s;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const title = titleSplit.map((message) => {
|
const title = titleSplit.map((message) => {
|
||||||
if (creatorName === message) {
|
if (channelName === message) {
|
||||||
return (
|
return (
|
||||||
<UriIndicator uri={notification_parameters.dynamic.comment_author} link />
|
<UriIndicator uri={channelUrl} link />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <LbcMessage>{__(' %message% ', { message })}</LbcMessage>;
|
return <LbcMessage>{__(' %message% ', { message })}</LbcMessage>;
|
||||||
|
@ -93,49 +130,6 @@ export default function Notification(props: Props) {
|
||||||
onClick: (e) => e.stopPropagation(),
|
onClick: (e) => e.stopPropagation(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let icon;
|
|
||||||
switch (notification_rule) {
|
|
||||||
case RULE.CREATOR_SUBSCRIBER:
|
|
||||||
icon = <Icon icon={ICONS.SUBSCRIBE} sectionIcon />;
|
|
||||||
break;
|
|
||||||
case RULE.COMMENT:
|
|
||||||
case RULE.CREATOR_COMMENT:
|
|
||||||
icon =
|
|
||||||
<UriIndicator uri={notification_parameters.dynamic.comment_author} link>
|
|
||||||
<ChannelThumbnail small uri={notification_parameters.dynamic.comment_author} />
|
|
||||||
</UriIndicator>;
|
|
||||||
break;
|
|
||||||
case RULE.COMMENT_REPLY:
|
|
||||||
icon =
|
|
||||||
<UriIndicator uri={notification_parameters.dynamic.reply_author} link>
|
|
||||||
<ChannelThumbnail small uri={notification_parameters.dynamic.reply_author} />
|
|
||||||
</UriIndicator>;
|
|
||||||
break;
|
|
||||||
case RULE.NEW_CONTENT:
|
|
||||||
icon =
|
|
||||||
<UriIndicator uri={notification_parameters.dynamic.channel_url} link>
|
|
||||||
<ChannelThumbnail small uri={notification_parameters.dynamic.channel_url} />
|
|
||||||
</UriIndicator>;
|
|
||||||
break;
|
|
||||||
case RULE.NEW_LIVESTREAM:
|
|
||||||
icon =
|
|
||||||
<UriIndicator uri={notification_parameters.dynamic.channel_url} link>
|
|
||||||
<ChannelThumbnail small uri={notification_parameters.dynamic.channel_url} />
|
|
||||||
</UriIndicator>;
|
|
||||||
break;
|
|
||||||
case RULE.DAILY_WATCH_AVAILABLE:
|
|
||||||
case RULE.DAILY_WATCH_REMIND:
|
|
||||||
case RULE.MISSED_OUT:
|
|
||||||
case RULE.REWARDS_APPROVAL_PROMPT:
|
|
||||||
icon = <Icon icon={ICONS.LBC} sectionIcon />;
|
|
||||||
break;
|
|
||||||
case RULE.FIAT_TIP:
|
|
||||||
icon = <Icon icon={ICONS.FINANCE} sectionIcon />;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
icon = <Icon icon={ICONS.NOTIFICATION} sectionIcon />;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleNotificationClick() {
|
function handleNotificationClick() {
|
||||||
if (!is_read) {
|
if (!is_read) {
|
||||||
doReadNotifications([id]);
|
doReadNotifications([id]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue