fix notification link to comment not working in some cases
the router scroll handling was interefering. I turned that off if exists as a search param
This commit is contained in:
parent
87247feb23
commit
5beb219ff6
5 changed files with 22 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import CommentsList from 'component/commentsList';
|
||||
import CommentCreate from 'component/commentCreate';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
|
@ -10,14 +9,9 @@ type Props = {
|
|||
function ChannelDiscussion(props: Props) {
|
||||
const uri = props.uri;
|
||||
return (
|
||||
<div>
|
||||
<section className="section">
|
||||
<CommentCreate uri={uri} />
|
||||
</section>
|
||||
<section className="section">
|
||||
<CommentsList uri={uri} />
|
||||
</section>
|
||||
</div>
|
||||
<section className="section">
|
||||
<CommentsList uri={uri} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import ChannelNew from 'page/channelNew';
|
|||
import BuyPage from 'page/buy';
|
||||
import NotificationsPage from 'page/notifications';
|
||||
import SignInWalletPasswordPage from 'page/signInWalletPassword';
|
||||
import { LINKED_COMMENT_QUERY_PARAM } from 'constants/comment';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { SITE_TITLE, WELCOME_VERSION } from 'config';
|
||||
|
||||
|
@ -115,6 +116,7 @@ function AppRouter(props: Props) {
|
|||
const entryIndex = history.index;
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const resetScroll = urlParams.get('reset_scroll');
|
||||
const hasLinkedCommentInUrl = urlParams.get(LINKED_COMMENT_QUERY_PARAM);
|
||||
|
||||
// For people arriving at settings page from deeplinks, know whether they can "go back"
|
||||
useEffect(() => {
|
||||
|
@ -152,8 +154,10 @@ function AppRouter(props: Props) {
|
|||
}, [entries, entryIndex, title, uri]);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, currentScroll);
|
||||
}, [currentScroll, pathname, resetScroll]);
|
||||
if (!hasLinkedCommentInUrl) {
|
||||
window.scrollTo(0, currentScroll);
|
||||
}
|
||||
}, [currentScroll, pathname, resetScroll, hasLinkedCommentInUrl]);
|
||||
|
||||
// react-router doesn't decode pathanmes before doing the route matching check
|
||||
// We have to redirect here because if we redirect on the server, it might get encoded again
|
||||
|
|
1
ui/constants/comment.js
Normal file
1
ui/constants/comment.js
Normal file
|
@ -0,0 +1 @@
|
|||
export const LINKED_COMMENT_QUERY_PARAM = 'lc';
|
|
@ -129,6 +129,12 @@ $thumbnailWidthSmall: 2rem;
|
|||
.comment__message {
|
||||
word-break: break-word;
|
||||
max-width: 35rem;
|
||||
|
||||
p {
|
||||
& + p {
|
||||
margin-top: var(--spacing-xxs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.comment__author {
|
||||
|
|
|
@ -44,6 +44,12 @@ h6 {
|
|||
font-size: 1rem;
|
||||
}
|
||||
|
||||
p {
|
||||
& + p {
|
||||
margin-top: var(--spacing-s);
|
||||
}
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
li {
|
||||
|
|
Loading…
Reference in a new issue