mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-31 09:21:27 +00:00
fix notification linking to channel page
This commit is contained in:
parent
37f18abb26
commit
5014b1a027
7 changed files with 58 additions and 15 deletions
|
@ -1,7 +1,17 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { withRouter } from 'react-router';
|
||||||
|
import { makeSelectCommentForCommentId } from 'redux/selectors/comments';
|
||||||
|
|
||||||
import ChannelDiscussion from './view';
|
import ChannelDiscussion from './view';
|
||||||
|
|
||||||
export default connect(
|
const select = (state, props) => {
|
||||||
null,
|
const { search } = props.location;
|
||||||
null
|
const urlParams = new URLSearchParams(search);
|
||||||
)(ChannelDiscussion);
|
const linkedCommentId = urlParams.get('lc');
|
||||||
|
|
||||||
|
return {
|
||||||
|
linkedComment: makeSelectCommentForCommentId(linkedCommentId)(state),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withRouter(connect(select)(ChannelDiscussion));
|
||||||
|
|
|
@ -4,13 +4,15 @@ import CommentsList from 'component/commentsList';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
|
linkedComment: ?any,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ChannelDiscussion(props: Props) {
|
function ChannelDiscussion(props: Props) {
|
||||||
const uri = props.uri;
|
const { uri, linkedComment } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="section">
|
<section className="section">
|
||||||
<CommentsList uri={uri} />
|
<CommentsList uri={uri} linkedComment={linkedComment} />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,13 @@ import React from 'react';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import Icon from 'component/common/icon';
|
import Icon from 'component/common/icon';
|
||||||
import DateTime from 'component/dateTime';
|
import DateTime from 'component/dateTime';
|
||||||
|
import Button from 'component/button';
|
||||||
import ChannelThumbnail from 'component/channelThumbnail';
|
import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import { MenuItem } from '@reach/menu-button';
|
import { MenuItem } from '@reach/menu-button';
|
||||||
import { formatLbryUrlForWeb } from 'util/url';
|
import { formatLbryUrlForWeb } from 'util/url';
|
||||||
import { useHistory } from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
|
import { parseURI } from 'lbry-redux';
|
||||||
|
import { PAGE_VIEW_QUERY, DISCUSSION_PAGE } from 'page/channel/view';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
notification: WebNotification,
|
notification: WebNotification,
|
||||||
|
@ -25,10 +28,20 @@ export default function Notification(props: Props) {
|
||||||
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 commentText = notification_rule === NOTIFICATION_COMMENT && notification_parameters.dynamic.comment;
|
||||||
let notificationLink = formatLbryUrlForWeb(notificationTarget);
|
let notificationLink = formatLbryUrlForWeb(notificationTarget);
|
||||||
|
let urlParams = new URLSearchParams();
|
||||||
if (notification_rule === NOTIFICATION_COMMENT && notification_parameters.dynamic.hash) {
|
if (notification_rule === NOTIFICATION_COMMENT && notification_parameters.dynamic.hash) {
|
||||||
notificationLink += `?lc=${notification_parameters.dynamic.hash}`;
|
urlParams.append('lc', notification_parameters.dynamic.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { isChannel } = parseURI(notificationTarget);
|
||||||
|
if (isChannel) {
|
||||||
|
urlParams.append(PAGE_VIEW_QUERY, DISCUSSION_PAGE);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
notificationLink += `?${urlParams.toString()}`;
|
||||||
|
|
||||||
let icon;
|
let icon;
|
||||||
switch (notification_rule) {
|
switch (notification_rule) {
|
||||||
case NOTIFICATION_CREATOR_SUBSCRIBER:
|
case NOTIFICATION_CREATOR_SUBSCRIBER:
|
||||||
|
@ -51,6 +64,11 @@ export default function Notification(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSeeNotification(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
doSeeNotifications([id]);
|
||||||
|
}
|
||||||
|
|
||||||
const Wrapper = menuButton
|
const Wrapper = menuButton
|
||||||
? (props: { children: any }) => (
|
? (props: { children: any }) => (
|
||||||
<MenuItem className="menu__link--notification" onSelect={handleNotificationClick}>
|
<MenuItem className="menu__link--notification" onSelect={handleNotificationClick}>
|
||||||
|
@ -98,8 +116,11 @@ export default function Notification(props: Props) {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="notification__time">
|
<div className="notification__extra">
|
||||||
<DateTime timeAgo date={notification.created_at} />
|
<div className="notification__time">
|
||||||
|
<DateTime timeAgo date={notification.created_at} />
|
||||||
|
</div>
|
||||||
|
{!is_seen && <Button className="notification__mark-seen" onClick={handleSeeNotification} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,9 +20,9 @@ import HelpLink from 'component/common/help-link';
|
||||||
import ClaimSupportButton from 'component/claimSupportButton';
|
import ClaimSupportButton from 'component/claimSupportButton';
|
||||||
import YoutubeBadge from 'component/youtubeBadge';
|
import YoutubeBadge from 'component/youtubeBadge';
|
||||||
|
|
||||||
const PAGE_VIEW_QUERY = `view`;
|
export const PAGE_VIEW_QUERY = `view`;
|
||||||
const ABOUT_PAGE = `about`;
|
const ABOUT_PAGE = `about`;
|
||||||
const DISCUSSION_PAGE = `discussion`;
|
export const DISCUSSION_PAGE = `discussion`;
|
||||||
const EDIT_PAGE = 'edit';
|
const EDIT_PAGE = 'edit';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -67,7 +67,6 @@ function ChannelPage(props: Props) {
|
||||||
} = useHistory();
|
} = useHistory();
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
const currentView = urlParams.get(PAGE_VIEW_QUERY) || undefined;
|
const currentView = urlParams.get(PAGE_VIEW_QUERY) || undefined;
|
||||||
const editInUrl = urlParams.get(PAGE_VIEW_QUERY) === EDIT_PAGE;
|
|
||||||
const [discussionWasMounted, setDiscussionWasMounted] = React.useState(false);
|
const [discussionWasMounted, setDiscussionWasMounted] = React.useState(false);
|
||||||
const editing = urlParams.get(PAGE_VIEW_QUERY) === EDIT_PAGE;
|
const editing = urlParams.get(PAGE_VIEW_QUERY) === EDIT_PAGE;
|
||||||
const { channelName } = parseURI(uri);
|
const { channelName } = parseURI(uri);
|
||||||
|
|
|
@ -13,7 +13,7 @@ $thumbnailWidthSmall: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment__create {
|
.comment__create {
|
||||||
padding-bottom: var(--spacing-l);
|
padding-bottom: var(--spacing-m);
|
||||||
font-size: var(--font-small);
|
font-size: var(--font-small);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,3 +106,16 @@
|
||||||
top: 0.75rem;
|
top: 0.75rem;
|
||||||
right: 1rem;
|
right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification__extra {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification__mark-seen {
|
||||||
|
height: 12px;
|
||||||
|
width: 12px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--color-primary);
|
||||||
|
margin-left: var(--spacing-s);
|
||||||
|
}
|
||||||
|
|
|
@ -83,8 +83,6 @@
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
--color-menu-background: var(--color-header-background);
|
--color-menu-background: var(--color-header-background);
|
||||||
--color-menu-background--selected: #5d646c;
|
|
||||||
--color-menu-background--active: #3a3f44;
|
|
||||||
--color-menu-icon: #a7a7a7;
|
--color-menu-icon: #a7a7a7;
|
||||||
--color-menu-icon-active: #d6d6d6;
|
--color-menu-icon-active: #d6d6d6;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue