- Introduce `NORMALIZED_MARKER` Symbol to mark normalized items.
- Optimize `normalizeDto` to return existing object if marked.
- Optimize `normalizeItems` to scan for markers and return input array if all items are valid and marked, avoiding unnecessary array allocation and object re-creation.
- Preserve safety logic in `runFeed` (handle nulls and always call normalizer) while benefiting from internal optimization.
Benchmark results show ~9x speedup for "Same Instance" updates and ~5x speedup for "Copy Array" updates in the feed pipeline.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Deleted `js/magnet.js` as it was a redundant wrapper for `js/magnetUtils.js`.
- Refactored `js/services/videoNotePayload.js`, `js/ui/components/EditModal.js`, and `js/nostr/nip71.js` to use `magnetUtils.js` and `magnetShared.js`.
- Updated `tests/magnet-utils.test.mjs` to remove tests for the deleted file.
- Removed unused exports `DEFAULT_FEED_CONFIG` and `DEFAULT_CONFIG_SCHEMA` from `js/feedEngine/engine.js` and `index.js`.
- Verified changes with unit tests.
- Implements `hasDisinterestedTag` helper in `js/feedEngine/utils.js` to check for disinterested tags in both raw Nostr tags and NIP-71 metadata.
- Updates `createBlacklistFilterStage` in `js/feedEngine/stages.js` to filter out videos matching `context.runtime.tagPreferences` disinterests.
- Ensures existing blacklist logic remains undisturbed.
- Verified with new unit test `tests/feed-engine-tag-pref.test.mjs` and existing feed engine tests.
This change introduces `createWatchHistoryProfileHydrationStage` to the
watch history feed pipeline. The stage resolves author profiles for
hydrated videos by:
1. Checking the global `getProfileCacheEntry` for cached profiles.
2. Batching missing profiles into a single Kind 0 relay request.
3. Updating the global cache (`setProfileCacheEntry`) with fetched data.
4. Attaching the resolved profile to `item.metadata.profile`.
This ensures that channel images populate correctly in the watch history
UI (both sidebar and profile modal).
This commit addresses issues with the watch history not updating dynamically and adds a manual refresh mechanism.
Changes:
- Added a "Refresh" button to the watch history view in `views/history.html` and `js/historyView.js`.
- Updated `watchHistoryService.js` to accept a `forceRefresh` option in `loadLatest`, which bypasses the cache freshness check and triggers a relay fetch.
- Updated `js/feedEngine/watchHistoryFeed.js` to propagate the `forceRefresh` flag from the runtime context to the service.
- Added user feedback (toast messages and logs) for "Clear Local History" and "Republish Now" actions.
- Updated `tests/watch-history.test.mjs` to align with the new `fetchHistory` signature.
- Enforce descending month order in `js/nostr/watchHistory.js` by explicitly sorting keys before flattening buckets.
- Update `js/feedEngine/watchHistoryFeed.js` and `js/historyView.js` to use `video.created_at` as a fallback sort key when `watchedAt` is missing or equal.
- Verified logic with `tests/verify_sort.mjs`.
The watch history hydration process was sometimes failing to retrieve video metadata, resulting in "Untitled video" cards. This was primarily due to only querying the generic relay list and potentially missing content hosted on specific relays.
This commit improves the robustness of `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js` by:
1. Collecting unique relay hints from the pointer objects (`item.pointer.relay`) of items needing hydration.
2. Merging these hints with the user's `readRelays` (or fallback `relays`) list. This ensures that if a specific video is known to exist on a niche relay, that relay is queried during the metadata fetch.
3. Replacing conditional debug logging with `devLogger.info` and `devLogger.warn` to provide detailed insights into the hydration process (item counts, selected relays, generated filters, and fetch results), aiding in future diagnosis.
These changes ensure the application attempts to fetch metadata from all relevant sources indicated by the history data itself.
The watch history hydration stage was failing silently when relay connections were unstable or misconfigured. This commit:
1. Replaces the conditional debug logger with `devLogger.info` and `devLogger.warn` to ensure visibility of critical hydration steps.
2. Adds detailed logging for item counts, missing ID/address lists, filter generation, and fetch results.
3. Updates the relay selection logic to prioritize `nostrClient.readRelays` over `nostrClient.relays`. This ensures that hydration attempts query the user's specific read-configured relays, which is crucial for fetching metadata when generic relays may be write-only or restricted.
These changes aid in diagnosing "Untitled video" issues and improve the robustness of the metadata fetch process.
The `createWatchHistoryHydrationStage` in the feed engine was incorrectly relying solely on `nostrClient.relays` for network fetches. This could cause hydration failures if `relays` contained write-only servers or was otherwise restricted. This commit updates the logic to prioritize `nostrClient.readRelays` if available, falling back to `nostrClient.relays`. This ensures that hydration attempts query the correct relays configured for reading data.
Fixes an issue where watch history items would display as "Untitled video" due to failed metadata resolution.
Updated `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js` to first check `nostrClient.allEvents` for video data before querying relays. This ensures that recently watched videos (which are already in memory) are instantly hydrated in the watch history list, fixing the "Untitled video" issue.
Additionally, implemented robust support for hydrating address pointers (`type: 'a'`) by scanning the cache and constructing proper relay filters for missing items. This covers cases where history items reference videos by `kind:pubkey:d-tag` rather than ID.
Updated `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js` to properly handle and hydrate watch history items that use address pointers (type 'a'), specifically fixing a bug where d-tags containing colons were being ignored.
Previously, only event ID pointers (type 'e') were being hydrated, and an initial fix for addresses failed for d-tags with colons. This change robustly parses address pointers, constructs appropriate filters, fetches the events, and correctly maps them back to the history items using a `normalizeAddressKey` utility that handles mixed-case pubkeys and complex d-tags.
Updated `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js` to properly handle and hydrate watch history items that use address pointers (type 'a').
Previously, only event ID pointers (type 'e') were being hydrated, causing videos watched via address pointers to display as "Untitled video" with missing metadata. This change parses the address pointers, constructs appropriate filters (normalizing pubkeys to lowercase while preserving d-tag case), fetches the events, and correctly maps them back to the history items using a robust `normalizeAddressKey` utility.
Updated `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js` to properly handle and hydrate watch history items that use address pointers (type 'a').
Previously, only event ID pointers (type 'e') were being hydrated, causing videos watched via address pointers to display as "Untitled video" with missing metadata. This change parses the address pointers, constructs appropriate filters, fetches the events, and correctly maps them back to the history items.
This introduces a new stage in the watch history feed pipeline that fetches missing video metadata from relays. Since watch history storage was optimized to store only event IDs, this hydration step ensures that the UI can display titles and thumbnails without requiring them to be persisted in the history payload itself.
- Implemented `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js`.
- Integrated `convertEventToVideo` to transform fetched events into usable video objects.
- Added a comprehensive integration test in `tests/watch-history.test.mjs` verifying the full flow from ID-only storage to hydrated feed items.
Removes the metadata argument from `WatchHistoryService.publishView` and cleans up the associated caching and resolution logic in `watchHistory.js` and `watchHistoryFeed.js`. Deletes `js/watchHistoryMetadata.js` as it is no longer used.
This simplification ensures watch history strictly manages pointers and timestamps, leaving metadata resolution to higher-level consumers. It also reduces the payload size and complexity of persisted history records.
Tests have been updated to reflect the API changes.