mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-29 17:02:28 +00:00
Merge pull request #801 from PR0M3TH3AN/codex/update-watch-history-exports-in-nostr.js
Refactor watch history forwarding
This commit is contained in:
2 files changed
+127
-16
No files matched your search
+70
-16
@@ -19,7 +19,25 @@ import {
|
||||
// 🔧 merged conflicting changes from codex/update-video-publishing-and-parsing-logic vs unstable
|
||||
import { deriveTitleFromEvent, magnetFromText } from "./videoEventUtils.js";
|
||||
import { extractMagnetHints } from "./magnet.js";
|
||||
import { createWatchHistoryManager, normalizePointerInput, pointerKey, chunkWatchHistoryPayloadItems, normalizeActorKey } from "./nostr/watchHistory.js";
|
||||
import {
|
||||
createWatchHistoryManager,
|
||||
normalizePointerInput,
|
||||
pointerKey,
|
||||
chunkWatchHistoryPayloadItems,
|
||||
normalizeActorKey,
|
||||
getWatchHistoryCacheTtlMs as getWatchHistoryCacheTtlMsFromManager,
|
||||
getWatchHistoryStorage as getWatchHistoryStorageFromManager,
|
||||
persistWatchHistoryEntry as persistWatchHistoryEntryToManager,
|
||||
cancelWatchHistoryRepublish as cancelWatchHistoryRepublishForManager,
|
||||
scheduleWatchHistoryRepublish as scheduleWatchHistoryRepublishForManager,
|
||||
getWatchHistoryFingerprint as getWatchHistoryFingerprintFromManager,
|
||||
ensureWatchHistoryBackgroundRefresh as ensureWatchHistoryBackgroundRefreshForManager,
|
||||
publishWatchHistorySnapshot as publishWatchHistorySnapshotWithManager,
|
||||
updateWatchHistoryList as updateWatchHistoryListWithManager,
|
||||
removeWatchHistoryItem as removeWatchHistoryItemWithManager,
|
||||
fetchWatchHistory as fetchWatchHistoryWithManager,
|
||||
resolveWatchHistory as resolveWatchHistoryWithManager,
|
||||
} from "./nostr/watchHistory.js";
|
||||
import {
|
||||
buildVideoPostEvent,
|
||||
buildVideoMirrorEvent,
|
||||
@@ -4117,44 +4135,72 @@ export class NostrClient {
|
||||
}
|
||||
|
||||
getWatchHistoryCacheTtlMs() {
|
||||
return this.watchHistory.getCacheTtlMs();
|
||||
return getWatchHistoryCacheTtlMsFromManager(this.watchHistory);
|
||||
}
|
||||
|
||||
getWatchHistoryStorage() {
|
||||
return this.watchHistory.getStorage();
|
||||
return getWatchHistoryStorageFromManager(this.watchHistory);
|
||||
}
|
||||
|
||||
persistWatchHistoryEntry(actorInput, entry) {
|
||||
this.watchHistory.persistEntry(actorInput, entry);
|
||||
persistWatchHistoryEntryToManager(this.watchHistory, actorInput, entry);
|
||||
}
|
||||
|
||||
cancelWatchHistoryRepublish(snapshotId = null) {
|
||||
this.watchHistory.cancelRepublish(snapshotId);
|
||||
cancelWatchHistoryRepublishForManager(this.watchHistory, snapshotId);
|
||||
}
|
||||
|
||||
scheduleWatchHistoryRepublish(snapshotId, operation, options = {}) {
|
||||
return this.watchHistory.scheduleRepublish(snapshotId, operation, options);
|
||||
return scheduleWatchHistoryRepublishForManager(
|
||||
this.watchHistory,
|
||||
snapshotId,
|
||||
operation,
|
||||
options,
|
||||
);
|
||||
}
|
||||
async getWatchHistoryFingerprint(actorInput, itemsOverride = null) {
|
||||
return this.watchHistory.getFingerprint(actorInput, itemsOverride);
|
||||
return getWatchHistoryFingerprintFromManager(
|
||||
this.watchHistory,
|
||||
actorInput,
|
||||
itemsOverride,
|
||||
);
|
||||
}
|
||||
ensureWatchHistoryBackgroundRefresh(actorInput = null) {
|
||||
return this.watchHistory.ensureBackgroundRefresh(actorInput);
|
||||
return ensureWatchHistoryBackgroundRefreshForManager(
|
||||
this.watchHistory,
|
||||
actorInput,
|
||||
);
|
||||
}
|
||||
async publishWatchHistorySnapshot(rawItems, options = {}) {
|
||||
return this.watchHistory.publishSnapshot(rawItems, options);
|
||||
return publishWatchHistorySnapshotWithManager(
|
||||
this.watchHistory,
|
||||
rawItems,
|
||||
options,
|
||||
);
|
||||
}
|
||||
async updateWatchHistoryList(rawItems = [], options = {}) {
|
||||
return this.watchHistory.updateList(rawItems, options);
|
||||
return updateWatchHistoryListWithManager(
|
||||
this.watchHistory,
|
||||
rawItems,
|
||||
options,
|
||||
);
|
||||
}
|
||||
async removeWatchHistoryItem(pointerInput, options = {}) {
|
||||
return this.watchHistory.removeItem(pointerInput, options);
|
||||
return removeWatchHistoryItemWithManager(
|
||||
this.watchHistory,
|
||||
pointerInput,
|
||||
options,
|
||||
);
|
||||
}
|
||||
async fetchWatchHistory(actorInput, options = {}) {
|
||||
return this.watchHistory.fetch(actorInput, options);
|
||||
return fetchWatchHistoryWithManager(this.watchHistory, actorInput, options);
|
||||
}
|
||||
async resolveWatchHistory(actorInput, options = {}) {
|
||||
return this.watchHistory.resolve(actorInput, options);
|
||||
return resolveWatchHistoryWithManager(
|
||||
this.watchHistory,
|
||||
actorInput,
|
||||
options,
|
||||
);
|
||||
}
|
||||
async listVideoViewEvents(pointer, options = {}) {
|
||||
if (!this.pool) {
|
||||
@@ -8271,10 +8317,10 @@ export const recordVideoView = (...args) =>
|
||||
nostrClient.recordVideoView(...args);
|
||||
|
||||
export const updateWatchHistoryList = (...args) =>
|
||||
nostrClient.updateWatchHistoryList(...args);
|
||||
updateWatchHistoryListWithManager(nostrClient.watchHistory, ...args);
|
||||
|
||||
export const removeWatchHistoryItem = (...args) =>
|
||||
nostrClient.removeWatchHistoryItem(...args);
|
||||
removeWatchHistoryItemWithManager(nostrClient.watchHistory, ...args);
|
||||
|
||||
export const listVideoViewEvents = (...args) => {
|
||||
if (typeof nostrClient.listVideoViewEvents !== "function") {
|
||||
@@ -8297,7 +8343,15 @@ export const countVideoViewEvents = (...args) => {
|
||||
return nostrClient.countVideoViewEvents(...args);
|
||||
};
|
||||
|
||||
export { normalizePointerInput, pointerKey, chunkWatchHistoryPayloadItems, normalizeActorKey };
|
||||
export {
|
||||
normalizePointerInput,
|
||||
pointerKey,
|
||||
chunkWatchHistoryPayloadItems,
|
||||
normalizeActorKey,
|
||||
parseWatchHistoryContentWithFallback,
|
||||
isNip04EncryptedWatchHistoryEvent,
|
||||
watchHistoryHelpers,
|
||||
} from "./nostr/watchHistory.js";
|
||||
export {
|
||||
getActiveSigner,
|
||||
setActiveSigner,
|
||||
|
||||
@@ -2196,6 +2196,63 @@ class WatchHistoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
export function getWatchHistoryCacheTtlMs(manager) {
|
||||
return manager.getCacheTtlMs();
|
||||
}
|
||||
|
||||
export function getWatchHistoryStorage(manager) {
|
||||
return manager.getStorage();
|
||||
}
|
||||
|
||||
export function persistWatchHistoryEntry(manager, actorInput, entry) {
|
||||
return manager.persistEntry(actorInput, entry);
|
||||
}
|
||||
|
||||
export function cancelWatchHistoryRepublish(manager, snapshotId = null) {
|
||||
return manager.cancelRepublish(snapshotId);
|
||||
}
|
||||
|
||||
export function scheduleWatchHistoryRepublish(
|
||||
manager,
|
||||
snapshotId,
|
||||
operation,
|
||||
options = {},
|
||||
) {
|
||||
return manager.scheduleRepublish(snapshotId, operation, options);
|
||||
}
|
||||
|
||||
export function getWatchHistoryFingerprint(
|
||||
manager,
|
||||
actorInput,
|
||||
itemsOverride = null,
|
||||
) {
|
||||
return manager.getFingerprint(actorInput, itemsOverride);
|
||||
}
|
||||
|
||||
export function ensureWatchHistoryBackgroundRefresh(manager, actorInput = null) {
|
||||
return manager.ensureBackgroundRefresh(actorInput);
|
||||
}
|
||||
|
||||
export function publishWatchHistorySnapshot(manager, rawItems, options = {}) {
|
||||
return manager.publishSnapshot(rawItems, options);
|
||||
}
|
||||
|
||||
export function updateWatchHistoryList(manager, rawItems = [], options = {}) {
|
||||
return manager.updateList(rawItems, options);
|
||||
}
|
||||
|
||||
export function removeWatchHistoryItem(manager, pointerInput, options = {}) {
|
||||
return manager.removeItem(pointerInput, options);
|
||||
}
|
||||
|
||||
export function fetchWatchHistory(manager, actorInput, options = {}) {
|
||||
return manager.fetch(actorInput, options);
|
||||
}
|
||||
|
||||
export function resolveWatchHistory(manager, actorInput, options = {}) {
|
||||
return manager.resolve(actorInput, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a watch-history manager. Callers supply the nostr client hooks needed
|
||||
* to sign, encrypt, fetch, and publish events. All dependencies are optional;
|
||||
|
||||
Reference in new issue
Block a user