Fix watch history sync when logged in

This commit is contained in:
thePR0M3TH3AN committed 2025-10-02 18:45:44 -04:00
1 parent c3ed4bc6ea
commit 762dbe5dcc
3 files changed
+146 -4

No files matched your search

+37 -1
View File
@@ -53,7 +53,43 @@ function resolveFlagEnabled() {
}
function getLoggedInActorKey() {
return normalizeActorKey(nostrClient?.pubkey);
const direct = normalizeActorKey(nostrClient?.pubkey);
if (direct) {
return direct;
}
if (typeof window !== "undefined") {
const appCandidate =
(window.bitvid && window.bitvid.app) || window.app || null;
if (appCandidate && typeof appCandidate === "object") {
if (typeof appCandidate.normalizeHexPubkey === "function") {
try {
const normalized = appCandidate.normalizeHexPubkey(
appCandidate.pubkey
);
if (normalized) {
return normalizeActorKey(normalized);
}
} catch (error) {
if (isDevMode) {
console.warn(
"[watchHistoryService] Failed to normalize app login pubkey:",
error
);
}
}
}
if (typeof appCandidate.pubkey === "string" && appCandidate.pubkey) {
const fallback = normalizeActorKey(appCandidate.pubkey);
if (fallback) {
return fallback;
}
}
}
}
return "";
}
function getSessionActorKey() {