scroll to top on opening notifications & thread pages
This commit is contained in:
@ -10,6 +10,7 @@ import BackButton from "@/Components/Button/BackButton";
|
|||||||
import Collapsed from "@/Components/Collapsed";
|
import Collapsed from "@/Components/Collapsed";
|
||||||
import Note from "@/Components/Event/EventComponent";
|
import Note from "@/Components/Event/EventComponent";
|
||||||
import NoteGhost from "@/Components/Event/Note/NoteGhost";
|
import NoteGhost from "@/Components/Event/Note/NoteGhost";
|
||||||
|
import ScrollToTop from "@/Components/ScrollToTop";
|
||||||
import { chainKey } from "@/Utils/Thread/ChainKey";
|
import { chainKey } from "@/Utils/Thread/ChainKey";
|
||||||
import { ThreadContext } from "@/Utils/Thread/ThreadContext";
|
import { ThreadContext } from "@/Utils/Thread/ThreadContext";
|
||||||
import { ThreadContextWrapper } from "@/Utils/Thread/ThreadContextWrapper";
|
import { ThreadContextWrapper } from "@/Utils/Thread/ThreadContextWrapper";
|
||||||
@ -224,6 +225,7 @@ export function ThreadRoute({ id }: { id?: string }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ThreadContextWrapper link={link}>
|
<ThreadContextWrapper link={link}>
|
||||||
|
<ScrollToTop />
|
||||||
<Thread />
|
<Thread />
|
||||||
</ThreadContextWrapper>
|
</ThreadContextWrapper>
|
||||||
);
|
);
|
||||||
|
@ -35,7 +35,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
|||||||
discriminator: login.publicKey?.slice(0, 12),
|
discriminator: login.publicKey?.slice(0, 12),
|
||||||
extra: rb => {
|
extra: rb => {
|
||||||
if (login.tags.item.length > 0) {
|
if (login.tags.item.length > 0) {
|
||||||
rb.withFilter().kinds([EventKind.TextNote]).tag("t", login.tags.item);
|
rb.withFilter().kinds([EventKind.TextNote, EventKind.Repost]).tag("t", login.tags.item);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}) as TimelineSubject,
|
}) as TimelineSubject,
|
||||||
|
12
packages/app/src/Components/ScrollToTop.tsx
Normal file
12
packages/app/src/Components/ScrollToTop.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
|
||||||
|
export default function ScrollToTop() {
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
@ -15,6 +15,8 @@ import { getNotificationContext } from "./getNotificationContext";
|
|||||||
import { NotificationGroup } from "./NotificationGroup";
|
import { NotificationGroup } from "./NotificationGroup";
|
||||||
const NotificationGraph = lazy(() => import("@/Pages/Notifications/NotificationChart"));
|
const NotificationGraph = lazy(() => import("@/Pages/Notifications/NotificationChart"));
|
||||||
|
|
||||||
|
import ScrollToTop from "@/Components/ScrollToTop";
|
||||||
|
|
||||||
export default function NotificationsPage({ onClick }: { onClick?: (link: NostrLink) => void }) {
|
export default function NotificationsPage({ onClick }: { onClick?: (link: NostrLink) => void }) {
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const { isMuted } = useModeration();
|
const { isMuted } = useModeration();
|
||||||
@ -51,6 +53,7 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<ScrollToTop />
|
||||||
<div className="main-content">
|
<div className="main-content">
|
||||||
{CONFIG.features.notificationGraph && (
|
{CONFIG.features.notificationGraph && (
|
||||||
<Suspense fallback={<PageSpinner />}>
|
<Suspense fallback={<PageSpinner />}>
|
||||||
|
Reference in New Issue
Block a user