Fix watch history hydration by preserving relay hints

Ensures that the relay hint is preserved when recording a video view, allowing the hydration logic to fetch the video details from the correct relay.
- Updated `resolveVideoPointer` in `js/utils/videoPointer.js` to accept a `relay` argument.
- Updated `playVideoByEventId`, `checkUrlParams`, and `deriveVideoPointerInfo` in `js/app.js` to pass the relay hint when resolving the video pointer.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-06 14:12:59 +00:00
1 parent a613d2d99f
commit e6a6ea6f78
2 files changed
+19 -8

No files matched your search

+8 -2
View File
@@ -839,6 +839,7 @@ class Application {
videoRootId: video.videoRootId,
dTag: dTagValue,
fallbackEventId: video.id,
relay: video.relay,
});
}
@@ -7625,16 +7626,20 @@ class Application {
const decoded = window.NostrTools.nip19.decode(maybeNevent);
if (decoded.type === "nevent" && decoded.data.id) {
const eventId = decoded.data.id;
const relay =
Array.isArray(decoded.data.relays) && decoded.data.relays.length
? decoded.data.relays[0]
: null;
// 1) check local map
let localMatch = this.videosMap.get(eventId);
if (localMatch) {
this.playVideoByEventId(eventId);
this.playVideoByEventId(eventId, { relay });
} else {
// 2) fallback => getOldEventById
this.getOldEventById(eventId)
.then((video) => {
if (video) {
this.playVideoByEventId(eventId);
this.playVideoByEventId(eventId, { relay });
} else {
this.showError("No matching video found for that link.");
}
@@ -8468,6 +8473,7 @@ class Application {
videoRootId: video.videoRootId,
dTag: dTagValue,
fallbackEventId: video.id || eventId,
relay: hint.relay || video.relay,
});
this.currentVideoPointer = pointerInfo?.pointer || null;
+11 -6
View File
@@ -16,28 +16,33 @@ export function resolveVideoPointer({
videoRootId,
dTag,
fallbackEventId,
relay,
} = {}) {
const normalizedPubkey = normalizeString(pubkey).toLowerCase();
const normalizedKind =
typeof kind === "number" && Number.isFinite(kind) ? kind : DEFAULT_VIDEO_KIND;
const pointerCandidates = [];
const normalizedRelay = normalizeString(relay);
const rootId = normalizeString(videoRootId);
if (rootId && normalizedPubkey) {
pointerCandidates.push(["a", `${normalizedKind}:${normalizedPubkey}:${rootId}`]);
const ptr = ["a", `${normalizedKind}:${normalizedPubkey}:${rootId}`];
if (normalizedRelay) ptr.push(normalizedRelay);
pointerCandidates.push(ptr);
}
const normalizedDTag = normalizeString(dTag);
if (normalizedDTag && normalizedPubkey) {
pointerCandidates.push([
"a",
`${normalizedKind}:${normalizedPubkey}:${normalizedDTag}`,
]);
const ptr = ["a", `${normalizedKind}:${normalizedPubkey}:${normalizedDTag}`];
if (normalizedRelay) ptr.push(normalizedRelay);
pointerCandidates.push(ptr);
}
const fallbackId = normalizeString(fallbackEventId);
if (fallbackId) {
pointerCandidates.push(["e", fallbackId]);
const ptr = ["e", fallbackId];
if (normalizedRelay) ptr.push(normalizedRelay);
pointerCandidates.push(ptr);
}
for (const pointer of pointerCandidates) {