perf: Batch video timestamp resolution to reduce N+1 network requests

- Implemented `hydrateVideoHistoryBatch` in `NostrClient` to fetch missing root events and sparse histories in a single `pool.list` request.
- Refactored `hydrateVideoHistory` to use shared helper methods `getLocalVideoHistory` and `_processAndCacheEvent`.
- Added `resolveVideoPostedAtBatch` to `PlaybackCoordinator` which delegates to the batched client method.
- Updated `VideoListView` to collect videos needing timestamp resolution and call the batch method, falling back to individual calls if necessary.
- Added regression test `tests/performance/resolvePostedAt.test.mjs` to verify reduced network calls.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-11 12:01:39 +00:00
1 parent 7164475c5e
commit b28e62963f
6 files changed
+380 -119

No files matched your search

+1
View File
@@ -950,6 +950,7 @@ export default class ApplicationBootstrap {
buildShareUrlFromEventId: (eventId) => app.buildShareUrlFromEventId(eventId),
getKnownVideoPostedAt: (video) => app.getKnownVideoPostedAt(video),
resolveVideoPostedAt: (video) => app.resolveVideoPostedAt(video),
batchResolveVideoPostedAt: (videos) => app.resolveVideoPostedAtBatch(videos),
canManageBlacklist: () => app.canCurrentUserManageBlacklist(),
canEditVideo: (video) => video?.pubkey === app.pubkey,
canDeleteVideo: (video) => video?.pubkey === app.pubkey,