Add paging and limits to nostr video subscription

This commit is contained in:
thePR0M3TH3AN committed 2026-01-02 14:11:41 -05:00
1 parent 0302b3cde6
commit ff07ed8e01
2 files changed
+83 -9

No files matched your search

+17 -5
View File
@@ -1122,10 +1122,19 @@ export class NostrService {
this.resolveInitialLoad({ videos: initial, reason: "cache" });
if (!getStoredVideoSubscription()) {
const subscription = this.nostrClient.subscribeVideos(() => {
const updated = this.nostrClient.getActiveVideos();
applyAndNotify(updated, "subscription");
});
const subscriptionOptions = {
// Start from the freshest cached timestamp to avoid replaying the full history;
// use loadOlderVideos when the user scrolls for backfill.
since: this.nostrClient.getLatestCachedCreatedAt() || undefined,
limit: this.nostrClient.clampVideoRequestLimit(200),
};
const subscription = this.nostrClient.subscribeVideos(
() => {
const updated = this.nostrClient.getActiveVideos();
applyAndNotify(updated, "subscription");
},
subscriptionOptions,
);
this.setVideoSubscription(subscription);
this.emit("subscription:started", { subscription });
}
@@ -1160,11 +1169,14 @@ export class NostrService {
return [];
}
const clampedLimit =
this.nostrClient?.clampVideoRequestLimit(limit) ?? limit ?? 0;
const filter = {
kinds: [VIDEO_KIND],
"#t": ["video"],
until,
limit,
limit: clampedLimit,
};
const collected = new Map();