scroll to top on opening notifications & thread pages
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
Martti Malmi 2024-02-12 12:36:26 +02:00
parent ff5d2ee32d
commit e2164800a9
4 changed files with 18 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import BackButton from "@/Components/Button/BackButton";
import Collapsed from "@/Components/Collapsed";
import Note from "@/Components/Event/EventComponent";
import NoteGhost from "@/Components/Event/Note/NoteGhost";
import ScrollToTop from "@/Components/ScrollToTop";
import { chainKey } from "@/Utils/Thread/ChainKey";
import { ThreadContext } from "@/Utils/Thread/ThreadContext";
import { ThreadContextWrapper } from "@/Utils/Thread/ThreadContextWrapper";
@ -224,6 +225,7 @@ export function ThreadRoute({ id }: { id?: string }) {
return (
<ThreadContextWrapper link={link}>
<ScrollToTop />
<Thread />
</ThreadContextWrapper>
);

View File

@ -35,7 +35,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
discriminator: login.publicKey?.slice(0, 12),
extra: rb => {
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,

View 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;
}

View File

@ -15,6 +15,8 @@ import { getNotificationContext } from "./getNotificationContext";
import { NotificationGroup } from "./NotificationGroup";
const NotificationGraph = lazy(() => import("@/Pages/Notifications/NotificationChart"));
import ScrollToTop from "@/Components/ScrollToTop";
export default function NotificationsPage({ onClick }: { onClick?: (link: NostrLink) => void }) {
const login = useLogin();
const { isMuted } = useModeration();
@ -51,6 +53,7 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
return (
<>
<ScrollToTop />
<div className="main-content">
{CONFIG.features.notificationGraph && (
<Suspense fallback={<PageSpinner />}>