Files
bitvid/js
google-labs-jules[bot]andPR0M3TH3AN 6e42d2c97c perf: Optimize nostrService video subscription updates
Optimizes the `subscribeVideos` callback in `js/services/nostrService.js` to handle video updates incrementally, avoiding O(N*M) complexity during high-volume updates (e.g., initial load).

Changes:
- Modified `js/nostr/videoEventBuffer.js` to include deleted videos in the flushed batch, allowing consumers to handle deletions incrementally.
- Updated `js/services/nostrService.js` to process `updatedVideos` incrementally:
  - Separates updates into active and deleted.
  - Updates `this.videosMap` directly (removing deleted, adding/updating active).
  - Filters and caches only the active updates (O(M)).
  - Emits `videos:updated` with the full sorted list (derived from the updated map) to maintain API contract with consumers.
  - Persists the full sorted list to localStorage.

This reduces the per-batch overhead significantly by avoiding O(N) filtering and map reconstruction for every batch of updates.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-26 17:48:37 +00:00
..
2026-02-21 15:46:35 -05:00
2026-01-23 02:09:08 -05:00
2026-01-26 21:49:18 -05:00
2026-02-22 15:56:05 -05:00
2026-02-21 19:59:47 -05:00
2026-01-30 16:51:01 -05:00