mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 01:08:50 +01:00
When clicked, don't use cached scroll position
This commit is contained in:
parent
fa5a468005
commit
81170c6d05
2 changed files with 17 additions and 7 deletions
|
@ -25,6 +25,7 @@ const Link = (props) => {
|
||||||
class={`${props.class || ''} ${isActive ? 'is-active' : ''}`}
|
class={`${props.class || ''} ${isActive ? 'is-active' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (routerLocation) states.prevLocation = routerLocation;
|
if (routerLocation) states.prevLocation = routerLocation;
|
||||||
|
props.onClick?.();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,6 +24,10 @@ import useTitle from '../utils/useTitle';
|
||||||
|
|
||||||
const LIMIT = 40;
|
const LIMIT = 40;
|
||||||
|
|
||||||
|
function resetScrollPosition(id) {
|
||||||
|
delete states.scrollPositions[id];
|
||||||
|
}
|
||||||
|
|
||||||
function StatusPage() {
|
function StatusPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
@ -190,6 +194,7 @@ function StatusPage() {
|
||||||
console.debug('scrollPosition', scrollPosition);
|
console.debug('scrollPosition', scrollPosition);
|
||||||
if (!!scrollPosition) {
|
if (!!scrollPosition) {
|
||||||
console.debug('Case 1', {
|
console.debug('Case 1', {
|
||||||
|
id,
|
||||||
scrollPosition,
|
scrollPosition,
|
||||||
});
|
});
|
||||||
scrollableRef.current.scrollTop = scrollPosition;
|
scrollableRef.current.scrollTop = scrollPosition;
|
||||||
|
@ -420,7 +425,13 @@ function StatusPage() {
|
||||||
<Status statusID={statusID} withinContext size="l" />
|
<Status statusID={statusID} withinContext size="l" />
|
||||||
</InView>
|
</InView>
|
||||||
) : (
|
) : (
|
||||||
<Link class="status-link" to={`/s/${statusID}`}>
|
<Link
|
||||||
|
class="status-link"
|
||||||
|
to={`/s/${statusID}`}
|
||||||
|
onClick={() => {
|
||||||
|
resetScrollPosition(statusID);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Status
|
<Status
|
||||||
statusID={statusID}
|
statusID={statusID}
|
||||||
withinContext
|
withinContext
|
||||||
|
@ -521,11 +532,7 @@ function StatusPage() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SubComments({
|
function SubComments({ hasManyStatuses, replies }) {
|
||||||
hasManyStatuses,
|
|
||||||
replies,
|
|
||||||
onStatusLinkClick = () => {},
|
|
||||||
}) {
|
|
||||||
// If less than or 2 replies and total number of characters of content from replies is less than 500
|
// If less than or 2 replies and total number of characters of content from replies is less than 500
|
||||||
let isBrief = false;
|
let isBrief = false;
|
||||||
if (replies.length <= 2) {
|
if (replies.length <= 2) {
|
||||||
|
@ -551,7 +558,9 @@ function SubComments({
|
||||||
<Link
|
<Link
|
||||||
class="status-link"
|
class="status-link"
|
||||||
to={`/s/${r.id}`}
|
to={`/s/${r.id}`}
|
||||||
onClick={onStatusLinkClick}
|
onClick={() => {
|
||||||
|
resetScrollPosition(r.id);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Status statusID={r.id} withinContext size="s" />
|
<Status statusID={r.id} withinContext size="s" />
|
||||||
{r.repliesCount > 0 && (
|
{r.repliesCount > 0 && (
|
||||||
|
|
Loading…
Reference in a new issue