From 84b70475d9e6707933d742919926cd2cc9514011 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 2 Oct 2025 16:53:09 -0400 Subject: [PATCH] Ensure watch history logging executes when service available --- js/app.js | 7 +++---- js/watchHistoryService.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index 54162d5b..211150f2 100644 --- a/js/app.js +++ b/js/app.js @@ -7585,10 +7585,9 @@ class bitvidApp { (async () => { let viewResult; try { - const watchHistoryEnabled = - watchHistoryService?.isEnabled?.() === true && - typeof watchHistoryService.publishView === "function"; - if (watchHistoryEnabled) { + const canUseWatchHistoryService = + typeof watchHistoryService?.publishView === "function"; + if (canUseWatchHistoryService) { viewResult = await watchHistoryService.publishView(thresholdPointer); } else if (typeof nostrClient?.recordVideoView === "function") { viewResult = await nostrClient.recordVideoView(thresholdPointer); diff --git a/js/watchHistoryService.js b/js/watchHistoryService.js index 00eeeec6..ff5ca635 100644 --- a/js/watchHistoryService.js +++ b/js/watchHistoryService.js @@ -835,6 +835,13 @@ async function publishView(pointerInput, createdAt, metadata = {}) { ); if (!isFeatureEnabled()) { + console.info( + "[watchHistoryService] Watch history feature disabled; skipping queue update.", + { + pointer: pointerInput, + createdAt, + } + ); return viewResult; } @@ -979,6 +986,13 @@ async function publishView(pointerInput, createdAt, metadata = {}) { async function snapshot(items, options = {}) { if (!isFeatureEnabled()) { + console.info( + "[watchHistoryService] Snapshot skipped because watch history feature is disabled.", + { + requestedItems: Array.isArray(items) ? items.length : 0, + reason: typeof options.reason === "string" ? options.reason : "manual", + } + ); return { ok: true, skipped: true, reason: "feature-disabled" }; } const reason = typeof options.reason === "string" ? options.reason : "manual"; @@ -1091,6 +1105,10 @@ async function snapshot(items, options = {}) { async function loadLatest(actorInput) { if (!isFeatureEnabled()) { + console.info( + "[watchHistoryService] loadLatest skipped because watch history feature is disabled.", + { actor: resolveActorKey(actorInput) || null } + ); return []; } const actorKey = resolveActorKey(actorInput);