mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 21:02:28 +00:00
Add paging and limits to nostr video subscription
This commit is contained in:
1 parent
0302b3cde6
commit
ff07ed8e01
2 files changed
+83
-9
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user