diff --git a/src/element/Timeline.tsx b/src/element/Timeline.tsx
index 3e9c6e34..2a57fae6 100644
--- a/src/element/Timeline.tsx
+++ b/src/element/Timeline.tsx
@@ -16,7 +16,7 @@ export interface TimelineProps {
* A list of notes by pubkeys
*/
export default function Timeline({ global, pubkeys, postsOnly = false }: TimelineProps) {
- const { main, others, loadMore } = useTimelineFeed(pubkeys, global);
+ const { main, others, loadMore, until } = useTimelineFeed(pubkeys, global);
const mainFeed = useMemo(() => {
return main?.sort((a, b) => b.created_at - a.created_at)?.filter(a => postsOnly ? !a.tags.some(b => b[0] === "e") : true);
@@ -37,7 +37,7 @@ export default function Timeline({ global, pubkeys, postsOnly = false }: Timelin
return (
<>
{mainFeed.map(eventElement)}
- {mainFeed.length > 0 ? : null}
+ {mainFeed.length > 0 ? : null}
>
);
}
\ No newline at end of file
diff --git a/src/feed/TimelineFeed.ts b/src/feed/TimelineFeed.ts
index 27914bf9..c7e905da 100644
--- a/src/feed/TimelineFeed.ts
+++ b/src/feed/TimelineFeed.ts
@@ -5,8 +5,7 @@ import { Subscriptions } from "../nostr/Subscriptions";
import useSubscription from "./Subscription";
export default function useTimelineFeed(pubKeys: HexKey | Array, global: boolean = false) {
- const TimeRange = 60 * 60; // 1 hr
- const [since, setSince] = useState(Math.floor(new Date().getTime() / 1000) - TimeRange);
+ const [until, setUntil] = useState();
const [trackingEvents, setTrackingEvent] = useState([]);
const subTab = global ? "global" : "follows";
@@ -23,11 +22,11 @@ export default function useTimelineFeed(pubKeys: HexKey | Array, global:
sub.Id = `timeline:${subTab}`;
sub.Authors = global ? undefined : new Set(pubKeys);
sub.Kinds = new Set([EventKind.TextNote, EventKind.Repost]);
- sub.Since = since;
- sub.Until = since + TimeRange;
+ sub.Limit = 20;
+ sub.Until = until;
return sub;
- }, [pubKeys, global, since]);
+ }, [pubKeys, global, until]);
const main = useSubscription(sub, { leaveOpen: true });
@@ -62,7 +61,10 @@ export default function useTimelineFeed(pubKeys: HexKey | Array, global:
main: main.notes,
others: others.notes,
loadMore: () => {
- setSince(s => s - TimeRange);
- }
+ let now = Math.floor(new Date().getTime() / 1000);
+ let oldest = main.notes.reduce((acc, v) => acc = v.created_at < acc ? v.created_at : acc, now);
+ setUntil(oldest);
+ },
+ until
};
}
\ No newline at end of file