mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-03 19:35:28 +00:00
Fix admin cache hydration cycle and guard QR code Android detection
This commit is contained in:
1 parent
677e673e1f
commit
6d7d5fc7ff
4 files changed
+134
-40
No files matched your search
+19
-4
@@ -10,9 +10,9 @@ import {
|
||||
isDevMode,
|
||||
} from "./config.js";
|
||||
import {
|
||||
nostrClient,
|
||||
getRegisteredNostrClient,
|
||||
requestDefaultExtensionPermissions,
|
||||
} from "./nostr.js";
|
||||
} from "./nostrClientRegistry.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import {
|
||||
buildAdminListEvent,
|
||||
@@ -40,6 +40,17 @@ function createError(code, message, cause) {
|
||||
return error;
|
||||
}
|
||||
|
||||
function requireNostrClient() {
|
||||
const client = getRegisteredNostrClient();
|
||||
if (!client) {
|
||||
throw createError(
|
||||
"nostr-unavailable",
|
||||
"Nostr relay pool is not initialized.",
|
||||
);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
function normalizeNpub(value) {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
@@ -350,10 +361,12 @@ function clearLegacyStorageFor(listKey) {
|
||||
}
|
||||
|
||||
function ensureNostrReady() {
|
||||
if (!nostrClient || !nostrClient.pool) {
|
||||
const nostrClient = requireNostrClient();
|
||||
|
||||
if (!nostrClient.pool) {
|
||||
throw createError(
|
||||
"nostr-unavailable",
|
||||
"Nostr relay pool is not initialized."
|
||||
"Nostr relay pool is not initialized.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -578,6 +591,7 @@ function extractNpubsFromEvent(event) {
|
||||
}
|
||||
|
||||
async function fetchLatestListEvent(filter, contextLabel = "admin-list") {
|
||||
const nostrClient = requireNostrClient();
|
||||
const relays = ensureNostrReady();
|
||||
|
||||
const normalizedFilter = {};
|
||||
@@ -876,6 +890,7 @@ function publishListWithFirstAcceptance(pool, relays, event, options = {}) {
|
||||
}
|
||||
|
||||
async function persistNostrState(actorNpub, updates = {}) {
|
||||
const nostrClient = requireNostrClient();
|
||||
ensureNostrReady();
|
||||
const permissionResult = await requestDefaultExtensionPermissions();
|
||||
if (!permissionResult.ok) {
|
||||
|
||||
Reference in new issue
Block a user