don't reload for you feed on refresh
This commit is contained in:
@ -6,6 +6,7 @@ import { useCallback, useMemo, useState } from "react";
|
||||
import { DisplayAs, DisplayAsSelector } from "@/Components/Feed/DisplayAsSelector";
|
||||
import { TimelineRenderer } from "@/Components/Feed/TimelineRenderer";
|
||||
import useTimelineFeed, { TimelineFeed, TimelineSubject } from "@/Feed/TimelineFeed";
|
||||
import useHistoryState from "@/Hooks/useHistoryState";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import { dedupeByPubkey } from "@/Utils";
|
||||
|
||||
@ -27,13 +28,15 @@ export interface TimelineProps {
|
||||
*/
|
||||
const Timeline = (props: TimelineProps) => {
|
||||
const login = useLogin();
|
||||
const feedOptions = useMemo(() => {
|
||||
return {
|
||||
const [openedAt] = useHistoryState(Math.floor(Date.now() / 1000), "openedAt");
|
||||
const feedOptions = useMemo(
|
||||
() => ({
|
||||
method: props.method,
|
||||
window: props.window,
|
||||
now: props.now,
|
||||
};
|
||||
}, [props]);
|
||||
now: props.now ?? openedAt,
|
||||
}),
|
||||
[props],
|
||||
);
|
||||
const feed: TimelineFeed = useTimelineFeed(props.subject, feedOptions);
|
||||
const displayAsInitial = props.displayAs ?? login.feedDisplayAs ?? "list";
|
||||
const [displayAs, setDisplayAs] = useState<DisplayAs>(displayAsInitial);
|
||||
|
@ -7,6 +7,7 @@ import { Link } from "react-router-dom";
|
||||
import { DisplayAs, DisplayAsSelector } from "@/Components/Feed/DisplayAsSelector";
|
||||
import { TimelineRenderer } from "@/Components/Feed/TimelineRenderer";
|
||||
import useTimelineFeed, { TimelineFeedOptions, TimelineSubject } from "@/Feed/TimelineFeed";
|
||||
import useHistoryState from "@/Hooks/useHistoryState";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import { dedupeByPubkey } from "@/Utils";
|
||||
|
||||
@ -27,6 +28,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
const login = useLogin();
|
||||
const displayAsInitial = props.displayAs ?? login.feedDisplayAs ?? "list";
|
||||
const [displayAs, setDisplayAs] = useState<DisplayAs>(displayAsInitial);
|
||||
const [openedAt] = useHistoryState(Math.floor(Date.now() / 1000), "openedAt");
|
||||
const subject = useMemo(
|
||||
() =>
|
||||
({
|
||||
@ -41,7 +43,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
}) as TimelineSubject,
|
||||
[login.follows.item, login.tags.item],
|
||||
);
|
||||
const feed = useTimelineFeed(subject, { method: "TIME_RANGE" } as TimelineFeedOptions);
|
||||
const feed = useTimelineFeed(subject, { method: "TIME_RANGE", now: openedAt } as TimelineFeedOptions);
|
||||
|
||||
// TODO allow reposts:
|
||||
const postsOnly = useCallback(
|
||||
|
@ -3,7 +3,7 @@ import { useLocation, useNavigationType } from "react-router-dom";
|
||||
|
||||
export default function ScrollToTop() {
|
||||
const { pathname } = useLocation();
|
||||
const navigationType = useNavigationType(); // This hook is available in React Router v6
|
||||
const navigationType = useNavigationType();
|
||||
|
||||
useEffect(() => {
|
||||
if (navigationType !== "POP") {
|
||||
|
Reference in New Issue
Block a user