Ensure watch history logging executes when service available

This commit is contained in:
thePR0M3TH3AN committed 2025-10-02 16:53:09 -04:00
1 parent a4eb4f2367
commit 84b70475d9
2 files changed
+21 -4

No files matched your search

+3 -4
View File
@@ -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);
+18
View File
@@ -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);